I have a Webform with masterpage(where the form tag is). Inside the content page I have a textbox and a submit button. I want to send the data to the next page using GET not P开发者_运维问答OST. How can I do this?
If it can apply to all pages:
<form method="get" ... >
<!-- content here -->
</form>
If you want only for a single, simple page:
protected void Submit_Click(object sender, EventArgs e)
{
string url = "NextPage.aspx?";
url = url + "&MyTxt1=" + MyTxt1.Text;
url = url + "&MyTxt2=" + MyTxt2.Text;
url = url + "&MyTxt3=" + MyTxt3.Text;
// etc.
Response.Redirect(url);
}
If you want to control the method from the content page:
// on the master page
public class SiteMaster : System.Web.UI.MasterPage
{
// replace form1 with the id of your form control
// make sure the form tag has runat="server"
public string Method
{
get { return form1.Method; }
set { form1.Method = value; }
}
// ...
}
// on the content page
protected void Page_Load(object sender, EventArgs e)
{
// replace SiteMaster with class type of the master class
((SiteMaster)this.Master).Method = "get";
}
精彩评论