質問

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