Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/331.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用Ajax模式弹出扩展程序时无法获取Cookie值_C#_Asp.net_Cookies_Ajaxcontroltoolkit_Modalpopupextender - Fatal编程技术网

C# 使用Ajax模式弹出扩展程序时无法获取Cookie值

C# 使用Ajax模式弹出扩展程序时无法获取Cookie值,c#,asp.net,cookies,ajaxcontroltoolkit,modalpopupextender,C#,Asp.net,Cookies,Ajaxcontroltoolkit,Modalpopupextender,以下是场景: 我有一个页面(Homepage.aspx)有一个按钮。 单击时,我通常将Cookie中的一些值传递到.CS文件中按钮的单击方法中,然后打开另一个aspx页面(Detail\u Report.aspx),在该页面中我从Cookie中检索值,然后显示使用我检索到的值的页面内容 最近,我决定实现Ajax弹出扩展程序,以显示Detail\u Report.aspx页面 我可以使用以下代码执行此操作: <asp:modalpopupextender id="ModalPopup

以下是场景: 我有一个页面(Homepage.aspx)有一个按钮。 单击时,我通常将Cookie中的一些值传递到.CS文件中按钮的单击方法中,然后打开另一个aspx页面(Detail\u Report.aspx),在该页面中我从Cookie中检索值,然后显示使用我检索到的值的页面内容

最近,我决定实现Ajax弹出扩展程序,以显示Detail\u 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);
protectedvoid Detail\u Report\u Click(对象发送方,事件参数e)
{
//字符串javaScript=“\n”+“DetailReport();\n”+”;
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();
//RegisterStartupScript(this.GetType(),“详细信息报告点击”,javaScript);
现在我的问题是弹出窗口即将出现,但我无法从Cookie中获取值,因为这些值是空的。因此,我的Detail\u Report.aspx页面无法正确显示
%
%If Session("ChildLoad") = "True" Then%>
 'Model Extender and panel
  <%end if%>
'型号扩展器和面板
然后在加载子页面时,检查会话状态是否为true,然后从会话或cookie中选取值,但要做到这一点,您需要在主页上启用post back

背后的想法是


当你刷新主页时,它也会从子页面触发加载事件。

这里也有同样的问题。找到了解决方案吗?还没有……搜索了一整天的google,但找不到一篇有帮助的帖子……我已经找到了这方面的工作,让我给你举个例子。我明白了你的意思,但让我更清楚地解释一下我的情况。在我的主页上,我有一些下拉列表。现在,只有在我从所有下拉列表中选择了值之后,我才会单击按钮调用子页面,并根据我在下拉列表中所做的选择在cookie中传递一个值。如果我没有使用Ajax模式弹出窗口,我可以正确地执行此操作,但是当我使用Ajax弹出窗口时,我可以做到这一点当我的主页被加载时,它也会加载子页面&因为我没有向cookies传递任何值,子页面加载不成功,因为它使用cookie中的值来获取数据。但是,如果在使用会话时将检查放在主页加载上,则可以避免加载子页面。当加载子页面时,甚至会触发主页加载t也一样,但这次通过会话检查加载子页面,以便您可以使用子页面加载上的cookies值。