简体   繁体   English

使用Ajax Modal Popup扩展器时无法获取Cookie值

[英]Unable to fetch Cookie values while using Ajax Modal Popup extender

Here's the scenario: I've a page( Homepage.aspx ) which has a button. 这是场景:我有一个带有按钮的页面( Homepage.aspx )。 When clicked i used to Pass some values in cookies inside _Click method of the button in .CS file and then open a different aspx page( Detail_Report.aspx ) where i was retrieving the values from the cookies and then display the content of the page which uses the values i've retrieved. 当我单击时,我习惯在.CS文件中按钮的_Click方法内的cookie中传递一些值,然后打开另一个aspx页面( Detail_Report.aspx ),在该页面中,我从cookie中检索值,然后显示该页面的内容。使用我检索到的值。

Now recently i've decided to implement Ajax pop-up extender to show the Detail_Report.aspx page. 现在,最近我决定实现Ajax弹出扩展器以显示Detail_Report.aspx页面。

I'm able to do this using the following code: 我可以使用以下代码执行此操作:

    <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>

Here's the button declaration: 这是按钮声明:

<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"/>

And this is what i've inside my onClick Method: 这就是我的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);

Now my problem is Pop-up is coming up, but i'm unable to fetch the values from cookies as those are blank. 现在我的问题是弹出窗口来了,但是我无法从cookie中获取值,因为它们是空白的。 As a result My Detail_Report.aspx page is not displaying correctly 结果,我的Detail_Report.aspx页面无法正确显示

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

and then on the load of child page check the session status if its true then pick the values from session or cookies but to do that you need to enable post back on your main page. 然后在子页面的加载中检查会话状态(如果为true),然后从会话或cookie中选择值,但为此您需要启用回发到主页上。

Idea behind is 背后的想法是

when you refresh the main page it will fire the load event from child page as well. 当您刷新主页时,也会触发子页面的加载事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM