2014-01-14 53 views
0

这里是场景: 我有一个页面(Homepage.aspx)它有一个按钮。 点击时,我用来传递cookie中的一些值_Click文件中的按钮的方法,然后打开一个不同的aspx页面(Detail_Report.aspx)我从cookie中检索值,然后显示使用我检索的值的页面。在使用Ajax模式弹出式扩展程序时无法获取Cookie值

现在最近我决定实施Ajax弹出式扩展程序,以显示Detail_Report.aspx页面。

我能够做到这一点使用下面的代码:

<asp:modalpopupextender id="ModalPopupExtender1" 
      runat="server" cancelcontrolid="btnCancel" 
      okcontrolid="btnOkay" targetcontrolid="Detail_Report" 
      popupcontrolid="DR" popupdraghandlecontrolid="PopupHeader" 
      drag="true" backgroundcssclass="ModalPopupBG"> 
     </asp:modalpopupextender> 

     <div class="popupConfirmation" id="DR" style="display: none"> 
    <iframe id="frameeditexpanse" src="DetailReport.aspx" frameborder="1"> 
    </iframe> 
    <div class="popup_Buttons" style="display: none"> 
     <input id="btnOkay" type="button" value="Done2" /> 
     <input id="btnCancel" type="button" value="Cancel2" /> 
    </div> 
</div> 

这里的按钮声明:

<asp:Button ID="Detail_Report" runat="server" 
       style="z-index: 1; left: 60px; top: 110px; position: absolute; width: 230px;" 
       Text="Detail Report" Font-Bold="True" BorderStyle="Solid" 
       Enabled="False" onclick="Detail_Report_Click"/> 

而这正是我在我的OnClick方法:

protected void Detail_Report_Click(object sender, EventArgs e) 
     { 
      //string javaScript = "<script language=JavaScript>\n" + "DetailReport();\n" + "</script>"; 
      Response.Cookies["proj"].Value = c_ProjName.Text.ToString(); 
      Response.Cookies["LOB"].Value = c_LOB.Text.ToString(); 
      Response.Cookies["release"].Value = c_ReleaseName1.Text.ToString(); 
      Response.Cookies["country"].Value = c_CountryName.Text.ToString(); 
      Response.Cookies["testenvkey"].Value = testenvkey.ToString(); 
      //ClientScript.RegisterStartupScript(this.GetType(), "Detail_Report_Click", javaScript); 

现在我的问题是弹出即将到来,但我无法获取价值因为那些是空白的,所以来自cookies。结果我Detail_Report.aspx页面无法显示正确

+0

同样的问题在这里。找到的解决方案? –

+0

尚未....搜索谷歌整整一天,但找不到一个单一的职位,可以帮助... – user2992534

+0

我发现在这方面的工作让我给你的例子。 –

回答

0
%If Session("ChildLoad") = "True" Then%> 
'Model Extender and panel 
    <%end if%> 

,然后在子页面的加载检查会话的状态是否是真的,然后挑选值从会话或Cookie,但要做到这一点,你需要在您的主页上启用回发。

背后的思想是

,当刷新主页,将火从子页面加载事件也是如此。

+0

我明白了你的意思,但是我可以更清楚地解释我的情况。 在我的主页上,我有一些下拉菜单。现在,只有在我从所有下拉列表中选择了值之后,我才会点击按钮来调用子页面,并将按照我在下拉列表中所做的选择在cookie中传递一个值。 如果我没有使用Ajax模式弹出窗口,但是当我使用Ajax弹出窗口时,我能够正确地执行此操作,当我的主页加载时,它也会加载子页面,因为&因为我没有给cookie传递任何值,子页面加载失败,因为它使用cookie中的值来获取数据 – user2992534

+0

,但是如果您在使用会话期间在主页上加载检查,则可以避免加载子页面。并且当您加载子页面时也会触发主页面加载事件,但是这次使用会话检查加载子页面,以便您可以在子页面加载中使用cookie值。 –

相关问题