Ajax ModalPopUp Extender在执行代码后面的前几行之前弹出

Ajax ModalPopUp Extendar pops up before execution of previous lines in code behind

本文关键字:几行 Extender ModalPopUp 执行 代码 Ajax      更新时间:2023-09-26

我有一个ajax模式弹出扩展程序,我正在使用它来显示包含一些数据的网格视图。似乎ModalPopup在数据绑定到GridView:之前弹出

  protected void grdrequisitionraisedbyme_RowCommand(object sender, GridViewCommandEventArgs e)
    {
    if (e.CommandName.Equals("viewhistory"))
        {
            GridViewRow clickedRow = ((LinkButton)e.CommandSource).NamingContainer as GridViewRow;
            LinkButton lnkclaimno = (LinkButton)clickedRow.FindControl("lnkclaimno");
            DataSet ds = new DataSet();
            ds = GetHistory(lnkclaimno.Text.Trim());
            grvcapexhistory.DataSource = null;
            grvcapexhistory.DataBind();
            if (ds.Tables[0].Rows.Count > 0)
            {
                grvcapexhistory.DataSource = ds.Tables[0];
                grvcapexhistory.DataBind();
                popup.Show(); 
            }
          }  
  }

我在绑定grvcapexhistory的地方放置了一个调试器,但即使断点尚未到达popup.Show() ,弹出窗口也已经弹出

<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="always">
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnrefresh" />
            <asp:AsyncPostBackTrigger ControlID="grdrequisitionraisedbyme" />
        </Triggers>
        <ContentTemplate>
            <div style="height: 300px; overflow-y: scroll;">
                <asp:GridView ID="grdrequisitionraisedbyme" runat="server" CssClass="tabledata" OnRowCommand="grdrequisitionraisedbyme_RowCommand">
                    <Columns>
                        <asp:TemplateField HeaderText="Capex/Po No">
                            <ItemTemplate>
                                <asp:LinkButton ID="lnkclaimno" runat="server" ForeColor="#3366FF" Text='<%# Eval("CapexNo") %>'
                                    CommandName="select"></asp:LinkButton>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="View History">
                            <ItemTemplate>
                                <asp:LinkButton ID="lnkviewhistory" runat="server" CommandName="viewhistory" ForeColor="#3366FF"
                                    Text="View History"></asp:LinkButton>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>
            </div>
            <br />
            <br />
            </div>
            <asp:Panel ID="pnlAddEdit" runat="server" CssClass="modalPopup" Style="display: none">
                <asp:Label Font-Bold="true" ID="Label4" runat="server" Text="Customer Details"></asp:Label>
                <br />
                <table align="center">
                    <tr>
                        <td colspan="6">
                         <asp:GridView ID="grvcapexhistory" runat="server" CssClass="tabledata">
            </asp:GridView>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        </td>
                        <td>
                            <asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClientClick="return Hidepopup()" />
                        </td>
                    </tr>
                </table>
            </asp:Panel>
            <asp:LinkButton ID="lnkFake" runat="server"></asp:LinkButton>
            <asp:ModalPopupExtender ID="popup" runat="server" DropShadow="false" PopupControlID="pnlAddEdit"
                TargetControlID="lnkFake" BackgroundCssClass="modalBackground">
            </asp:ModalPopupExtender>
        </ContentTemplate>
    </asp:UpdatePanel>

去掉Ajax弹出窗口并使用以下内容。它会解决你的问题。

<asp:Panel ID="popup" runat="server" visible="false">
 <table style="position: fixed; z-index: 1; left: 0px; top: 0px"   border="0"  width="100%" height="100%">
    <tr>
        <td valign="top"  align="center"  >
        // below div will automatically expand as much as needed 
        <div class="yourmodalclass" style=" display:inline-block;margin-top:90px; ">        
        //put your GridView ID="grvcapexhistory" and other stuff here
 </div>
 </td>
 </table>
 </asp:Panel>

使用弹出窗口随时显示此弹出窗口。Visible=true;

在弹出窗口中放一个按钮。onclick=弹出。Visible=false;

这个弹出窗口将让你完全控制,没有任何回邮问题。

你可以在这里看到这一点:http://atldunia.com/youtube/Zpopup.aspx