Search code examples
asp.netpostdatamultiple-forms

ASP.Net using multiple form tag and post them to another page


I don't know it's even possible but I try to achieve to post data from one page to another using the second form.
The problem is I need a form tag for the user interface containing callback panels etc. I want to put a second form with some hidden-field:

<form id="postForm" method="post" action="target.aspx">
    <input type="hidden" id="id" />
</form>

I submit the form from javascript with jquery:

$("#id").val(id);
$("#postForm").submit();

Is there a way access the value of the hidden field on the target page?


Solution

  • You should give the hidden field a name attribute:

    <input type="hidden" id="id" name="id" />
    

    You'll then be able to use Request.Form in your target page to access the posted data:

    string postedId = Request.Form["id"];