asp.net mvc 2 - Post with MVC 2, including values outside of form -
i'm pretty new mvc 2 , i'm having problems figuring out how post values lies outside form.
this code simplified:
<input type="text" id="textboxoutsideform"/>     <% using (html.beginform("edit", "home", formmethod.post)) {%>     <%: html.validationsummary(true) %>       <%: html.textboxfor(model => model.stuff) %>          <input type="submit" value="save" /> <% } %>   textboxoutsideform can changed user , when pushing save want include value control action in controller. great if use model binding @ same time. great:
[httppost] public actionresult edit(int id, model model, string valuefromtextbox)   or formcollection , value.. know in simplified example put textbox inside of form, in real life control 3rd party , creating loads of of other stuff, need grab value jquery maybe , post it..
is possible?
thanks
if use normal form post inputs inside form sent server. achieve looking need submit form using ajax. example:
$(function() {     $('form').submit(function() {         $.ajax{             url: this.action,             type: this.method,             data: $(this).clone().append($('#textboxoutsideform').clone()).serialize(),             success: function(result) {                 alert('form posted');             }         });         return false;     }); });   also don't forget give name input field outside form.
Comments
Post a Comment