asp.net - Post back Method not get call on button click in MVC4 -
i have created login page without _layout.cshtml in mvc4 , added 2 text box button. when click button no getting post back. have tried using breakpoint. pls help. code
@model mapprojectmvc.models.loginmodel @{ layout = null; } <!doctype html> <html> <head> <meta name="viewport" content="width=device-width" /> <title>special spots</title> @styles.render("~/content/css") @scripts.render("~/bundles/modernizr") </head> <body> <div class="loginbox"> <div class="loginhead"> <img src="img/logo.png" alt="special spots - responsive admin panel" title="special spots - responsive admin panel" /> </div> <div class="control-group"> <label for="inputemail"> user name</label> @html.textboxfor(a => a.username) </div> <div class="control-group"> <label for="inputpassword"> password</label> @html.textboxfor(a => a.password) </div> <div class="control-group" style="margin-bottom: 5px;"> </div> <div class="form-actions"> <button type="submit" class="btn btn-block"> sign in</button> </div> </div> @scripts.render("~/bundles/jquery") </body> </html> [httpget] public actionresult login() { return view(); } [httppost] public actionresult login(loginmodel lm) { var userid = new objectparameter("userid",typeof(string)); var res = new objectparameter("res",typeof(int32)); int = ssc.validateadminlogin(lm.username, lm.password, userid, res); if (convert.toint32(res) == 1) { } else { modelstate.addmodelerror("", "login details wrong."); } return view(lm); }
you have put input elements , submit button in form. purpose can use asp.net mvc html helper extension form html.beginform()
way:
@using(html.beginform()) { <div class="loginbox"> <div class="loginhead"> <img src="img/logo.png" alt="special spots - responsive admin panel" title="special spots - responsive admin panel" /> </div> <div class="control-group"> <label for="inputemail"> user name</label> @html.textboxfor(a => a.username) </div> <div class="control-group"> <label for="inputpassword"> password</label> @html.textboxfor(a => a.password) </div> <div class="control-group" style="margin-bottom: 5px;"> </div> <div class="form-actions"> <button type="submit" class="btn btn-block"> sign in</button> </div> </div> }
there many overloads of html.beginform()
, see overloads here
Comments
Post a Comment