How to apply input which has a type email to HTML Helper in Asp.net MVC3 Razor. For example:
<input type="email" name="name" value=" " placeholder="[email protected]" />
Is there alternative in Razor?
Creating HTML Helpers with Static Methods The easiest way to create a new HTML Helper is to create a static method that returns a string. Imagine, for example, that you decide to create a new HTML Helper that renders an HTML <label> tag. You can use the class in Listing 2 to render a <label> .
Unlike HtmlHelpers, a tag helper is a class that attaches itself to an HTML-compliant element in a View or Razor Page. The tag helper can, through its properties, add additional attributes to the element that a developer can use to customize the tag's behavior.
The Input Tag Helper binds an HTML <input> element to a model expression in your razor view. The Input Tag Helper: Generates the id and name HTML attributes for the expression name specified in the asp-for attribute. asp-for="Property1.
You can use Html.TextBox method.
@Html.TextBox("name","", new { type = "email", placeholder = "[email protected]" })
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With