服务器控件post值到其它页面

如果是button激活postback的话,可以使用button的PostBackUrl属性。

例如

<asp:button id="Button2"
  text="Post value to another page" 
  postbackurl="Button.PostBackUrlPage2cs.aspx" 
  runat="Server">
  </asp:button>

在Button.PostBackUrlPage2cs.aspx页面的Page_Load中使用PreviousPage来取得前面页面上控件的值

 void Page_Load (object sender, System.EventArgs e)
  {
  string text;

  // Get the value of TextBox1 from the page that 
  // posted to this page.
  text = ((TextBox)PreviousPage.FindControl("TextBox1")).Text;

  // Check for an empty string.
  if (text != "")
  PostedLabel.Text = "The string posted from the previous page is "
  + text + ".";
  else
  PostedLabel.Text = "An empty string was posted from the previous page.";
  }

参考:
http://msdn.microsoft.com/zh-cn/library/system.web.ui.webcontrols.button.postbackurl.aspx

原文地址:https://www.cnblogs.com/superfeeling/p/2134172.html