Click here to Skip to main content
15,885,978 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi friends

i am new to asp.net MVC application.so please help me..

I created one model,view ,controller
Create and show are the two views

this is my view code

<form method="post" action="Create" runat="server">
    <div>
        <%if (Model != null)
          { %>
        <%=Model.Id%>
        <%=Model.Name%>
        <%=Model.Dateofbirth%>
        <%=Model.Designation%>
        <%=Model.Salary%>
        <%} %>
    </div>
    <%=Html.TextBoxFor(m=>m.Id )%><br />
    <%=Html.TextBoxFor(m=>m.Name) %><br />
    <%=Html.TextBoxFor(m=>m.Dateofbirth) %><br />
    <%=Html.TextBoxFor(m=>m.Designation )%><br />
    <%=Html.TextBoxFor(m=>m.Salary )%><br />
    <input type="button" value="Create"  />
    </form>


i wrote two methods in controller

like
[HttpGet]
       public ActionResult Create()
       {
           return View();
       }

       [AcceptVerbs(HttpVerbs.Post)]
       public ActionResult Create(Employee emp)
       {
           return View("Show", emp);
       }


in post back i want to transfer the data entered by the user to another view i.e "show" in my example

can u guys plz suggest me


here post back action is not hitting .every time the same get method is hitting in post back also
Posted
Updated 30-Nov-11 23:07pm
v4

1 solution

Try changing the BUTTON to SUBMIT.

Replace

<input type="button" value="Create" onclick="" />

with
<input type="submit" value="Create" onclick="" />
 
Share this answer
 
Comments
hitech_s 1-Dec-11 5:08am    
thank you very much
hbp33 18-Jul-13 2:31am    
thank you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900