Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 16, 2012 08:03 AM by Dino He - MSFT
Member
9 Points
40 Posts
Apr 13, 2012 09:29 AM|LINK
Can we acces view state value in another page
If yes then tell me how
Thanks
All-Star
16400 Points
3173 Posts
Apr 13, 2012 09:36 AM|LINK
View state is applicable only for a page, if you want to trasnfer data to another page then use some other technique like query string or store values on the server.
But, Cross Page Posting orServer.transfer is used to redirect the user to other page then ViewState can be accessed across pages.
Contributor
5446 Points
735 Posts
Apr 13, 2012 09:50 AM|LINK
I don't know if ViewState is applicable in WebMatrix.
Anyway "The ViewState object is useful for storing objects between postbacks to the same page. It cannot be used for passing values to other pages."
At the same link where I have taken this citation, they explain a lot of methods for passing data between web pages: Data Passing Round-Up
Star
8068 Points
1023 Posts
Microsoft
Apr 16, 2012 08:03 AM|LINK
Hi
I really agree with nijhawan.sau....This is only possible if Cross Page Posting or Server.transfer is used to redirect the user to other page.
And here is some details.
ViewStateContainer.aspx.cs public partial class ViewStateContainer : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { ViewState["Page1"] = "Page1 ViewState"; Server.Transfer("AccessViewState.aspx"); } public StateBag ReturnViewState() { return ViewState; } } AccessViewState.aspx.cs public partial class AccessViewState : System.Web.UI.Page { private StateBag PreviousPageViewState { get { StateBag returnValue = null; if (PreviousPage != null) { Object objPreviousPage = (Object)PreviousPage; MethodInfo objMethod = objPreviousPage.GetType().GetMethod ("ReturnViewState"); return (StateBag)objMethod.Invoke(objPreviousPage, null); } return returnValue; } } protected void Page_Load(object sender, EventArgs e) { if (PreviousPage != null) { if (PreviousPageViewState != null) { Label1.Text = PreviousPageViewState["Page1"].ToString(); } } } }
Hope it helpful.
zeeshanfazal
Member
9 Points
40 Posts
View state
Apr 13, 2012 09:29 AM|LINK
Can we acces view state value in another page
If yes then tell me how
Thanks
nijhawan.sau...
All-Star
16400 Points
3173 Posts
Re: View state
Apr 13, 2012 09:36 AM|LINK
View state is applicable only for a page, if you want to trasnfer data to another page then use some other technique like query string or store values on the server.
But, Cross Page Posting orServer.transfer is used to redirect the user to other page then ViewState can be accessed across pages.
GmGregori
Contributor
5446 Points
735 Posts
Re: View state
Apr 13, 2012 09:50 AM|LINK
I don't know if ViewState is applicable in WebMatrix.
Anyway "The ViewState object is useful for storing objects between postbacks to the same page. It cannot be used for passing values to other pages."
At the same link where I have taken this citation, they explain a lot of methods for passing data between web pages: Data Passing Round-Up
Dino He - MS...
Star
8068 Points
1023 Posts
Microsoft
Re: View state
Apr 16, 2012 08:03 AM|LINK
Hi
I really agree with nijhawan.sau....This is only possible if Cross Page Posting or Server.transfer is used to redirect the user to other page.
And here is some details.
ViewStateContainer.aspx.cs public partial class ViewStateContainer : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { ViewState["Page1"] = "Page1 ViewState"; Server.Transfer("AccessViewState.aspx"); } public StateBag ReturnViewState() { return ViewState; } } AccessViewState.aspx.cs public partial class AccessViewState : System.Web.UI.Page { private StateBag PreviousPageViewState { get { StateBag returnValue = null; if (PreviousPage != null) { Object objPreviousPage = (Object)PreviousPage; MethodInfo objMethod = objPreviousPage.GetType().GetMethod ("ReturnViewState"); return (StateBag)objMethod.Invoke(objPreviousPage, null); } return returnValue; } } protected void Page_Load(object sender, EventArgs e) { if (PreviousPage != null) { if (PreviousPageViewState != null) { Label1.Text = PreviousPageViewState["Page1"].ToString(); } } } }Hope it helpful.
If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework