Yes, this is possible through
1. Passing the data you want to persist, through the Query String. and
2. if multiple requests for the same page, by maintaining a ViewState.
Page1.aspx:
<asp:label ID="lbl" runat="server" />
<asp:Button ID="btn1" runat="server" Text="btn1" onclick="data" />
<asp:Button ID="btn2" runat="server" Text="btn2" onclick="movepage" />
aspx.cs:
Page_Load(object sender, EventArgs e)
{
if(!string.IsNullOrWhiteSpace(Request.QueryString["autoId"]))
{
var x = Request.QueryString["autoId"].ToString();
Response.Write(x);
}
protected void data(object sender, EventArgs e)
{
lbl.Text = (Request.QueryString["~/Page1.aspx?autoId=5"]).ToString();
}
protected void movepage(object sender, EventArgs e)
{
Response.Redirect("~/otherPage.aspx",true);
}
otherPage.aspx:
<asp:Button ID="btn3" runat="server" Text="OldPage" Onclick="oldpage" />
otherPage.aspx.cs:
protected void oldpage(object sender, EventArgs e)
{
Response.Redirect("~/Page1.aspx?autoId=5",true);
}
Following your instructions:
1.click on btn1, autoid value 5 appears on the screen.
2. click on btn2, redirects you to other page.
3. click on btn3, redirects you to the old page & that persists the value 5.
Regards,
Awesome Coding !! :)
Bhuwan87rawat, if this helps please login to Mark As Answer. | Alert Moderator