You are on page 1of 1

ASP.

Net MVC Razor Helpers Cheat Sheet

http://httputility.com/various/razorhelperscheatsheet.html

ASP .Net MVC Razor Helpers Cheat Sheet HtmlHelper


Method Action Generates a hidden form field (anti-forgery token) that is validated when the form is submitted. HTML-encodes the string (as an attribute). Writes an opening <form> tag to the response. Writes an opening <form> tag for the route. Returns a check box input element. Returns a check box input element for the model. Returns a single-selection select element. Returns a single-selection select element for the model. HTML-encodes the string. Renders the closing </form> tag to the response. Returns a hidden input element. Returns a hidden input element for the model. Returns a multi-select select element. Returns a multi-select select element for the model. Returns a password input element. Returns a password input element for the model. Returns a radio button input element. Returns a radio button input element for the model. Renders a partial view (.cshtml). Returns an anchor element (a element) that contains the virtual path of the specified action. Returns the specified textarea element. Returns the specified textarea element for the model. Returns a text input element. Returns a text input element for the model. Returns a text input element for the model. <a href="action">text</a> <textarea name="name">value</textarea> <textarea name="name">value</textarea> <input type="text" name="name" value="value" /> <input type="text" name="name" value="value" /> <input type="text" name="name" value="value" /> </form> <input type="hidden" value="value" name="name" /> <input type="hidden" value="value" name="name" /> <select multiple="multiple" name="name" id="name"></select> <select multiple="multiple" name="name" id="name"></select> <input type="password" value="value" name="name" /> <input type="password" value="value" name="name" /> <input type="radio" value="value" name="name" checked="checked" /> <input type="radio" value="value" name="name" checked="checked" /> <form action="/controller/action/"> <form action="route"> <input type="checkbox" name="name" id="name" checked="checked" /> <input type="checkbox" name="name" id="name" checked="checked" /> <select name="name" id="name"></select> <select name="name" id="name"></select> Output ActionLink(s:text, s:action, o:attributes) Writes an anchor tag to a link for a specific action. <a href="action">text</a> AntiForgeryToken(s:salt, s:domain, s:path) AttributeEncode(s: input) BeginForm(s:action, s:controller, o:values) BeginRouteForm(s:routeName) CheckBox(s:name, b:checked) CheckBoxFor(e:expression) DropDownList(s:name, list:selectlistitems) DropDownListFor(e:expression, list:selectlistitems) Encode(s:input) EndForm() Hidden(s:name, o:value) HiddenFor(e:expression) ListBox(s:name, list:selectlistitems) ListBoxFor(e:expression, list:selectlistitems) Password(s:name, o:value) PasswordFor(e:expression) RadioButton(s:name, o:value, b:checked) RadioButtonFor(e:expression, o:value) Partial(s:name, o:model) RouteLink(s:text, s:routeName) TextArea(s:name, s:value) TextAreaFor(e:expression) TextBox(s:name, o:value) TextBoxFor(e:expression) TextBoxFor(e:expression)

UrlHelper
Method Action(s:action, s:controller) Content(s:path) Encode(s:url) RouteUrl(s:route) Action Generates a fully qualified URL to an action method. Converts a virtual (relative) path to an application absolute path. Encodes special characters in a URL string into character-entity equivalents. Generates a fully qualified URL for the specified route name. Output

Prepared by Egor Pavlikhin (pabros.com.au)

1 of 1

6/17/2012 2:36 PM

You might also like