开发者

sending asp.net forms data using $.post

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 t开发者_JAVA技巧o use it in asp.net context


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


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...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜