문제

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