伙计们 我有2页. Page_1和Page_2. 在Page_1中,我EneableViewstate="true"位于页面顶部. Page_1的链接也重定向到Page_2. 下面是Page_1的Page_Load()代码.
Hi Guys I have 2 pages. Page_1 and Page_2. In Page_1 I EneableViewstate="true" on top of the page. Also Page_1 has a link that redirects to Page_2. the code for Page_Load() of Page_1 is below.
if (!Page.IsPostBack) { loadgrdAvailableStaffOnPageLoad(); loadgrvViewAppointmentsOnPageLoad(); } else if (Page.IsPostBack) { loadgrdAvailableStaffOnPageLoadViewState(); loadgrvViewAppointmentsOnPageLoadViewState(); }在Page_2中,我在下面的代码中有取消"按钮
In Page_2 I have button "cancel" with this code below
Response.Redirect("Page_1.aspx");// So it goes to Page_1如果因为混淆而错了,现在纠正我. 在最初的Page_Load()上,期望应用程序位于下面的"if"语句中:
Now correct me if am wrong because am confuse. On initial Page_Load() am expecting the application to go inside this "if" statement below:
if (!Page.IsPostBack) { loadgrdAvailableStaffOnPageLoad(); loadgrvViewAppointmentsOnPageLoad(); }然后从Page_2返回后,应用程序应该正在加载 这部分:
Then after coming back from Page_2, the application should be loading this part:
else if (Page.IsPostBack) { loadgrdAvailableStaffOnPageLoadViewState(); loadgrvViewAppointmentsOnPageLoadViewState(); }从Page_2返回后,我该怎么做才能恢复Page_1信息?
What can I do to restore Page_1 information after coming back from Page_2??
推荐答案ViewState仅在您停留在同一页面上时可用.如果要在页面之间导航,则需要查看其他保留信息的方法: 1.会话状态: msdn.microsoft/en-us/library/ms178581.aspx [ ^ ] 2. QueryString:使用QueryString在页面之间传递变量 [ ^ ] 如果信息比仅仅几个原始值(整数,字符串等)更复杂,我将使用会话状态.它可以让您在不同页面的请求中保留复杂的对象. ViewState is only available if you stay on the same page. If you''re navigating between pages, you''ll need to look at other methods of persisting the information: 1. Session State: msdn.microsoft/en-us/library/ms178581.aspx[^] 2. QueryString: Passing variables between pages using QueryString[^] If the information is in any way more complex than just a couple of primitive values (integer, string etc) I''d use Session State. It''ll let you persist complex objects across requests for different pages.
更多推荐
在使用EnableviewState ="true"时感到困惑.
发布评论