Skip to content

Instantly share code, notes, and snippets.

@jesperbjensen
Created June 14, 2013 14:29
Show Gist options
  • Save jesperbjensen/5782264 to your computer and use it in GitHub Desktop.
Save jesperbjensen/5782264 to your computer and use it in GitHub Desktop.
Alternative HtmlHelper Syntax
@using (Html.BeginRouteForm(Route.Stuff, FormMethod.Get, new {@class = "myForm", data_hello = "this"}))
{
...
}
@using (Html.Form.Method(FormMethod.Get).Src(Route.Stuff).Class("myForm").Data_Hello("this"))
{
}
@jesperbjensen
Copy link
Author

For a textbox, it could be:

@Html.TextBoxFor(x=>x.Name, new { type = "number", @class = "long", data_hello = "this", disabled = "disabled"})

@Html.Input(x => x.Name).Type("number").Disabled.Class("long").Data_Hello("this");

@jesperbjensen
Copy link
Author

Or maybe just make the attributes using text:

@Html.Input(x => x.Name).Custom("type='number' class='long' data-hello='this'")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment