0
Posted on 3:31 AM by Softminer and filed under ,

using Strongly Typed Html Helpers will map the model to the view and it will help to have compile time checking of the views.

in views instead of using
<%=Html.TextBox("username", Model.UserName)%>

you can use

<%= Html.TextBoxFor( m => m.UserName)%>

in controller:

public ActionResult LogOn(string userName, string password)

use

public ActionResult LogOn(LoginViewModel loginviewModel)

moreover you dont need to use ValueProvider["UserName"].AttemptedValue to access Html value and you can use model directly.

and for adding attribute
<%= Html.TextBoxFor(model => model.UserName , new { @calss="SingleTextBox" }) %>
0
Responses to ... ASP.NET MVC 2 Strongly Typed Html Helpers