【问题标题】:Displaying Modal Popup in Code Behind在后面的代码中显示模式弹出窗口
【发布时间】:2013-07-23 07:52:48
【问题描述】:

我正在展示 ajaxcontrol 工具包 ModalPopupExtender,以便在单击按钮时从后面的代码中显示。 在我的按钮上单击我正在上传文件并发送电子邮件,在发送电子邮件后我将显示模态弹出窗口几秒钟,然后我将用户重定向到索引页面。

我遇到的问题是 ModalPopup 仅在我不重定向时才显示 这是我的aspx代码

<input type="btmodel" runat="server" style="display: none">
     <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btmodel"
            PopupControlID="Panel1" PopupDragHandleControlID="PopupHeader" Drag="true" DropShadow="true"
            OkControlID="OkButton" CancelControlID="CancelButton" BackgroundCssClass="ModalPopupBG">
        </ajaxToolkit:ModalPopupExtender>
        <asp:Panel ID="Panel1" Style="display: none" runat="server">
            <div class="HellowWorldPopup">
                <div class="PopupHeader" id="PopupHeader">
                    Progress</div>
                <div class="PopupBody">
                    <p>
                       Processing.....</p>
                </div>
                <div class="Controls">
                    <input id="btnOkay" type="button" value="Ok" onclick="OkScript()" />
                </div>
            </div>
        </asp:Panel>

和我的按钮点击代码

  protected void btnupload_Click(object sender, EventArgs e)
  {
  //File uploading 
  //Sending Email

   ModalPopupExtender1.Show();
   Response.Redirect("Default.aspx");//If I comment this line,then modal is showing
  }

我在 ModalPopupExtender1.Show() 之前也试过这个,但没有运气

System.Threading.Thread.Sleep(1000);

【问题讨论】:

    标签: c# asp.net


    【解决方案1】:

    关键是在用户关闭弹出窗口时进行重定向,而不是在您显示它时进行。 编写代码来处理“OnOkScript”或“OnCancelScript”并在那里进行重定向。

    【讨论】:

      【解决方案2】:

      让自己意识到在 ASP.NET(或任何网络服务器/客户端浏览器环境)中,您的服务器端代码将执行到最后,然后将结果发送到客户端浏览器。这不是一种设计来回的通信。

      【讨论】:

        猜你喜欢
        • 2010-12-15
        • 2011-09-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多