Question

I am very much new to ASP.NET MVC 2.

I am trying to make simple login screen from Custom Login Screen (The tutorial is in MVC 4)

This is my Login View and the rest Model and controller is same as described in the Linked example.

 <div class="editor-label">
            <%=Html.LabelFor(u => u.UserName)%>
        </div>
        <div class="editor-field">
            <%=Html.TextBoxFor(u => u.UserName)%>
            <%=Html.ValidationMessageFor(u => u.UserName)%>
        </div>

  <input type="submit" value="Log In" />

How can i link it with Model and controller ?

Please help

Était-ce utile?

La solution

You can use the answer given by Bios

in the first method any button with type submit will call the action defined in the

<% using (Html.BeginForm("Action", "Controller", null, FormMethod.Post, new {@id = "value")) {%>

same goes for <form method="post" action="/Controller/Action">

Autres conseils

If your using a razor as view engine try Html.BeginForm() for form submission.

Example:

<% using (Html.BeginForm("Action", "Controller", null, FormMethod.Post, new {@id = "value")) {%>

 //Your form goes here

<% } %>

Or

<form method="post" action="/Controller/Action">
   //Your form goes here
</form>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top