i am dynamically create contents and buttons into my code behind \"tree.aspx.cs\" page
sbmainTbl.AppendFormat(\"
-
To pass pass values using asp.net you need to follow the asp.net way.
First on the first page you place that value on a page control, I prefer on your case a hidden field, that is also post back to any page.
Then you add your value to that field
ValueHiddenField.value = CellText(dtparent.Rows[0]["UnitName"].ToString())
and you make also a public field so the second page can read it
public string ValueHiddenField
{
get
{
return ValueHiddenField.value;
}
}
And you say to the button to post back to the second page using the PostBackUrl
field of the button.
Now this is the way you get your data from second page:
On the redirect page declare what is the previous page on aspx as:
<%@ Reference Page ="~/PreviousPageName.aspx" %>
and on code behind on second page you get the value as:
if (Page.PreviousPage != null)
{
if (Page.PreviousPage is PreviousPageClassName)
{
Label1.Text = ((PreviousPageClassName)Page.PreviousPage).ValueHiddenField;
}
else
{
Label1.Text = "no value";
}
}
else
Label1.Text = "no value from previous page";
Similar answers:
cross page posting
Cross-page posting. Is it a good pratice to use PreviousPage in Asp.net?
讨论(0)
- 热议问题