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

有帮助吗?

解决方案

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">

其他提示

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>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top