0

I have an asp.net page Default1.aspx with 2 text fields and a button. I want to use $.post to pass data from Default1.aspx to Default2.aspx.

My question is how can i do that and then read the values in Default2.aspx?

Note ihave seen the serialize() method but cannot figure how to use it in asp.net context

1

2 Answers 2

1

Try this:

Default1.aspx:

<input id="t1" />
<input id="t2" />
<button onclick="postData()">submit</button>

<script>
   function postData(){
      var t1 = $('#t1').val();
      var t2 = $('#t2').val();
      $.post('Default2.aspx',{text1:t1,text2:t2},function(result){
         //do something with the result
      });
   }
</script>

Default2.aspx:

PageLoad Event:

String t1 = Request["text1"]; //c#
String t2 = Request["text2"]; //c#

dim t1 as string = Request("text1") //vb
dim t2 as string = Request("text2") //vb
Sign up to request clarification or add additional context in comments.

Comments

0

I think you can just do the post like you wish and then read the values in Page_Load of Default2.aspx using PreviousPage.FindControl(...) to get the value of ASP.NET controls you need. You might also want to check that PreviousPage is actually the Default1.apsx page...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.