C # Survival Path-html Helper

Source: Internet
Author: User
Tags actionlink

Original reference: Http://www.cnblogs.com/jyan/archive/2012/07/23/2604474.html

Msdn:http://msdn.microsoft.com/zh-cn/library/system.web.mvc.htmlhelper_methods%28v=vs.108%29.aspx

Inheritance Hierarchy

System.Object

System.Web.Mvc.HtmlHelper

System.web.mvc.htmlhelp<tmodel>

Namespaces:

System.Web.Mvc

ActionLink-Link to action method

BeginForm-marks the beginning of the form and links to the action method that renders the form

CheckBox-Render check box

DropDownList-Render drop-down list

Hidden-Embed non-rendered information in the form for users to view

ListBox-Render list box

Password-Renders a text box for entering a password

RadioButton-Render radio button

TextArea-Render text area (multiline text box)

TextBox-Render text box

------

ActionLink:

1@Html. ActionLink ("This is a connection","Index","Home")2 the wording with QueryString3@Html. ActionLink ("This is a connection","Index","Home",New{page=1},NULL)4@Html. ActionLink ("This is a connection","Index",New{page=1 })5 there are other HTML attributes to be written6@Html. ActionLink ("This is a connection","Index","Home",New{id="Link1" })7@Html. ActionLink ("This is a connection","Index",NULL,New{id="Link1" })8 querystring and HTML attributes exist at the same time9@Html. ActionLink ("This is a connection","Index","Home",New{page =1},New{id ="Link1" })Ten@Html. ActionLink ("This is a connection","Index",New{page =1},New{id ="Link1"})

Build Result:

1<a href="/"> This is a connection </a>2 the wording with QueryString3<a href="/?page=1"> This is a connection </a>4<a href="/?page=1"> This is a connection </a>5 there are other HTML attributes to be written6<a href="/? Length=4"Id="Link1"> This is a connection </a>7<a href="/"Id="Link1"> This is a connection </a>8 querystring and HTML attributes exist at the same time9<a href="/?page=1"Id="Link1"> This is a connection </a>Ten<a href="/?page=1"Id="Link1"> This is a connection </a>

--------

RouteLink

It's the same with ActionLink.

1@Html. RouteLink ("about the"," About",New { })2 with QueryString3@Html. RouteLink ("about the"," About",New{page =1 })4@Html. RouteLink ("about the"," About",New{page =1},New{id ="Link1"})

Build Result:

1 <a href="/about"> About </a>2 <a href="/ about?page=1"> About </a>3 <a href="/about?page=1" id="link1"> About </a>

------

Beginfrom:

1 @using (html.beginform ("index","home", FormMethod.Post)) {2}4Or5 @Html. BeginForm (" Index " " Home " , FormMethod.Post) 6 @Html. EndForm ()

Build Result:

1 <form action="/home/index" method="post"> </form>

-------

TextArea:

1 @Html. TextArea ("input5"39,null)  233null)

Build Result:

<textarea cols="9"Id="INPUT5"Name="INPUT5"Rows="3">beverages</textarea><textarea cols="3"Id="CategoryName"Name="CategoryName"Rows="3">Beverages</textarea>

-------

DropDownList:

1@Html. DropDownList ("DDL1", (SelectList) viewdata["Categories"],"--select one--")2@Html. dropdownlistfor (A = A.categoryname, (selectlist) viewdata["Categories"],"--select one--",New{@class ="DropDownList"})

Build Result:

1<SelectId="DDL1"Name="DDL1">2<option value="">--select one--</option>3<option value="1">Beverages</option>4<option value="2">Condiments</option>5<option selected="selected"Value="3">Confections</option>6<option value="4">dairy products</option>7<option value="5">Grains/Cereals</option>8<option value="6">Meat/Poultry</option>9<option value="7">Produce</option>Ten<option value="8">Seafood</option> One</Select> A<Select class="DropDownList"Id="CategoryName"Name="CategoryName"> -<option value="">--select one--</option> -<option value="1">Beverages</option> the<option value="2">Condiments</option> -<option value="3">Confections</option> -<option value="4">dairy products</option> -<option value="5">Grains/Cereals</option> +<option value="6">Meat/Poultry</option> -<option value="7">Produce</option> +<option value="8">Seafood</option> A</Select>

-------

RenderPartial:

Not to be continued

C # Survival Path-html Helper

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.