1. 程式人生 > >Asp.net MVC HtmlHelper學習

Asp.net MVC HtmlHelper學習

ActionLink

<%: Html.ActionLink("超級連結的文字","Index","UserInfo",new {name="itcast"},new {demo="ssss"}) %>

//相當於連結到 UserInfo Control下的 Index Action  後面是傳遞的引數 路徑:http://localhost/UserInfo/Index?name=itcast 


TextBox

<%: Html.TextBox("UserName","你好傳智播客") %>
       
CheckBox

        
<%: Html.CheckBox("Foot",true) %>


DropDownList

 <%: Html.DropDownList("City") %>

        public ActionResult HtmlHelper()
        {

            ViewData["City"] = new List<SelectListItem>()
            {
                new SelectListItem(){Selected = false,Text = "北京",Value="1"},
                new SelectListItem(){Selected = true,Text = "上海",Value="2"},
                new SelectListItem(){Selected = false,Text = "廣州",Value="3"}
            };
            return View();
        }

RadioButton

<%=Html.RadioButton("radio","boy",true%>
<%=Html.RadioButton("radio","girl",false%>