how can manage state management system between two page

Posted by Bhuwan87rawat under ASP.NET on 8/20/2012 | Points: 10 | Views : 771 | Status : [Member] | Replies : 1
In my application
i take one page and two button on this page when a press the one button show data and press second button then goes to second page
and then in second page i have take one button when i press the button then return the first page and show previous data..
this is possible....in asp.net



regard
Bhuwan




Responses

Posted by: Vasanthmvp on: 8/20/2012 [Member] Starter | Points: 25

Up
0
Down
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

Login to post response