Null Pointer
Null Pointer

Reputation: 9309

how to send data outside form while submitting -MVC ,HTML

In my view there is a form shown below

    <% using (Html.BeginForm("SaveRecords", "Search", FormMethod.Post))
                 { %>
                <input type="submit" value="Save" class="button_62" title="Save" />
                 // some controls
                <%} %>

My need is that there is another form in the same view.While clicking save button i need to get value of a particular text box that is outside the form submitting .I cant put that control in same form.And i cant use ajax request to send data. Is there anyway i can append data outside of the form before submitting it?

I want to get value of that textbox(out sid the submitted form) in controller Saverecords ..

Upvotes: 1

Views: 2710

Answers (1)

James Kyburz
James Kyburz

Reputation: 14503

Here is an answer using javascript

using jQuery you could set a hidden field in the the form above containing the same value as the control that resides in the other form.

if you add an id to your form above then.

$("#myform").submit(function() {
  $("#myhiddenId").val($("#fieldInOtherFormId").val());
});    

Upvotes: 7

Related Questions