簡體   English   中英

使用Ajax Modal Popup擴展器時無法獲取Cookie值

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

這是場景:我有一個帶有按鈕的頁面( Homepage.aspx )。 當我單擊時,我習慣在.CS文件中按鈕的_Click方法內的cookie中傳遞一些值,然后打開另一個aspx頁面( Detail_Report.aspx ),在該頁面中,我從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);

現在我的問題是彈出窗口來了,但是我無法從cookie中獲取值,因為它們是空白的。 結果,我的Detail_Report.aspx頁面無法正確顯示

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

然后在子頁面的加載中檢查會話狀態(如果為true),然后從會話或cookie中選擇值,但為此您需要啟用回發到主頁上。

背后的想法是

當您刷新主頁時,也會觸發子頁面的加載事件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM