Mike Pliam
June 8th, 2010, 11:26 AM
I have a web source page that contains a textbox, id = txtV1. I wish to cross-page post this data to a target page. Say that txtV1 contains the text "0.12345". Now on a button click, the C# code behind is supposed to send the data to the target page where it is to be displayed in a similar textbox, id = txtV1.
The source page code behind looks like this:
public partial class _Default : System.Web.UI.Page
{
protected String s1;
protected void buttonSend_Click(object sender, EventArgs e)
{
// get the string values from the controls
s1 = txtV1.Text;
//s1 = "Dustin Byfuglien";
Response.Redirect("Target.aspx?Field1="+s1);
}
The target page code looks like this:
public partial class Target : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
String tsv1;
tsv1 = Request.QueryString["Field1"];
txtV1.Text = tsv1;
}
}
While it appears to me that this should work, it does not -- only "0" appears in the target textbox. However, if one uncomments the s1 string assignment on the source page, the name "Dustin Byfuglien" appears as expected in the target textbox.
I cannot figure out why the string assignments s1 = txtV1.Text; and s1 = "Dustin Byfuglien"; should behave so differently.
Please help. I need to be able to send numeric data in text form from one page to another, and from what I can tell, this should be the simplest way to do it. (It would be far more efficient to simply generate a data set on one page and send it to another without have to go through the rigamarole of first setting the number in a textbox control.)
The source page code behind looks like this:
public partial class _Default : System.Web.UI.Page
{
protected String s1;
protected void buttonSend_Click(object sender, EventArgs e)
{
// get the string values from the controls
s1 = txtV1.Text;
//s1 = "Dustin Byfuglien";
Response.Redirect("Target.aspx?Field1="+s1);
}
The target page code looks like this:
public partial class Target : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
String tsv1;
tsv1 = Request.QueryString["Field1"];
txtV1.Text = tsv1;
}
}
While it appears to me that this should work, it does not -- only "0" appears in the target textbox. However, if one uncomments the s1 string assignment on the source page, the name "Dustin Byfuglien" appears as expected in the target textbox.
I cannot figure out why the string assignments s1 = txtV1.Text; and s1 = "Dustin Byfuglien"; should behave so differently.
Please help. I need to be able to send numeric data in text form from one page to another, and from what I can tell, this should be the simplest way to do it. (It would be far more efficient to simply generate a data set on one page and send it to another without have to go through the rigamarole of first setting the number in a textbox control.)