asp.net mvc - How to pass an object using the Ajax.BeginForm() helper -
i trying utilize ajax.beginform post message server , need give name form, i.e. utilize parameter htmlattributes. using next signature:
@using (ajax.beginform("sendemail", "contacts", null, new ajaxoptions { httpmethod = "post", updatetargetid = "sendmessagearea" }, new { name = "sendemail" })) this code doestn't work, updates whole page , controller expecting object paramenter:
public actionresult sendemail(contacts contacts)
here view:
<div class="row"> <div class="large-12 columns" > @using (ajax.beginform("sendemail", "contacts", null, new ajaxoptions { httpmethod = "post", updatetargetid = "sendmessagearea" }, new { name = "sendemail" })) { <fieldset class="form-group"> <legend>leave message</legend> <div class="panel"> <div class="row"> <div class="large-offset-2 large-8 columns"> <div class="row"> <div class="large-2 columns"> <div class="form-group"> @html.labelfor(model => model.name, new { @class = "control-label" }) </div> </div> <div class="large-8 columns"> @html.textbox("name", model.name, new { placeholder = "your name..." }) @html.validationmessagefor(model => model.name) </div> <div class="large-2 columns"> </div> </div> <div class="row"> <div class="large-2 columns"> <div class="form-group"> @html.labelfor(model => model.email, new { @class = "control-label" }) </div> </div> <div class="large-8 columns"> <div class="form-group"> @html.textbox("email", model.email, new { placeholder = "your email..." }) @html.validationmessagefor(model => model.email) </div> </div> <div class="large-2 columns"> </div> </div> <div class="row"> <div class="large-2 columns"> <div class="form-group"> @html.labelfor(model => model.message, new { @class = "control-label" }) </div> </div> <div class="large-8 columns"> @html.textarea("message", model.message, new { placeholder = "your message here...", @class = "comment-control", id = "message" }) @html.validationmessagefor(model => model.message) </div> <div class="large-2 columns"> </div> </div> <div class="row"> <div class="large-offset-8 large-3 columns"> <input type='submit' style='position:absolute;top:0;left:-9999px;width:1px;height:1px' /> <a class='submit-button' href="javascript:sendemail.submit()"> <span class='submit-button-inner'>submit</span> </a> </div> </div> </div> <div class="large-2 columns"> </div> </div> </div> </fieldset> } </div> and partial view:
<span class="success label">@resources.contacts.index.successsendmessage</span> i think problem should related routevalues parameter because if utilize simple illustration without htmlattributes , routevalues works well. guess?
ajax asp.net-mvc partial-views
No comments:
Post a Comment