簡體   English   中英

在gridview的鏈接按鈕單擊中未引發彈出窗口

[英]Popup not raised in a linkbutton click of gridview

我正在嘗試從網格視圖顯示一個彈出窗口。 但是,當我嘗試在網站上運行以下代碼時,彈出面板不可見。 但是,當我刪除面板的樣式(即display = none;)時,它就像面板一樣顯示而不是彈出窗口。 在網格視圖中單擊鏈接按鈕的按鈕,我試圖顯示一個彈出窗口。 幫我...

<asp:UpdatePanel runat="server" ID="up1">
                        <ContentTemplate>
                            <asp:GridView ID="minidata" CssClass="table" runat="server" AutoGenerateColumns="false" DataKeyNames="abstract">

                                <Columns>
                                    <asp:BoundField DataField="pid" HeaderText="MyFileId" />
                                    <asp:BoundField DataField="video" HeaderText="MyFileurl" />
                                    <asp:TemplateField HeaderText="abstract">
                                        <ItemTemplate>
                                            <asp:LinkButton ID="lnkDownload" runat="server" Text="Download" OnClick="lnkDownload_Click"></asp:LinkButton>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                            </asp:GridView>

                            <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>


                            <asp:Panel runat="server" ID="panel1" Height="200px" Width="300px" BorderStyle="Solid" BorderWidth="2px" style="display:none;">
                                <div>
                                    <table>
                                        <tr>
                                            <td>
                                                <asp:Label runat="server" Text="sacca"></asp:Label>
                                            </td>
                                            <td>
                                                <asp:TextBox ID="emails" runat="server"></asp:TextBox>
                                            </td>
                                            <td>
                                                <asp:LinkButton runat="server">5e76d</asp:LinkButton>
                                            </td>
                                        </tr>
                                    </table>
                                </div>

                            </asp:Panel>
                            <asp:ModalPopupExtender ID="ModalPopupExtender1" PopupControlID="panel1" TargetControlID="Button1" runat="server"></asp:ModalPopupExtender>
                            <asp:Button ID="Button1" Style="display: none;" runat="server" Text="Button" />
                        </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="minidata" />
                        </Triggers>
                    </asp:UpdatePanel>

在.cs文件中

    LinkButton lnkbtn = sender as LinkButton;
    GridViewRow gvrow = lnkbtn.NamingContainer as GridViewRow;
    string filePath = minidata.DataKeys[gvrow.RowIndex].Value.ToString();
    HiddenField1.Value = filePath;
    emails.Text = "myemail";
    this.ModalPopupExtender1.Show();

在此處輸入圖片說明

當我檢查網站時,找不到頁面中顯示的面板

在此處輸入圖片說明

是的,我以前知道。 您必須模擬對modalPopupExtender的TargetControl的單擊。 因此,在您的代碼中似乎是Button1。

因此,嘗試通過替換它來做到這一點

<asp:LinkButton ID="lnkDownload" runat="server" Text="Download" OnClick="lnkDownload_Click"></asp:LinkButton>

<asp:LinkButton ID="lnkDownload" runat="server" Text="Download" onclick="$('[id$=Button1]').click()"></asp:LinkButton>

您的服務器端代碼對這種方法沒有用

編輯

好的,您還沒有在應用程序^^中使用JQuery。

您可以在應用程序中添加JQuery還是約束?

如果是這樣,請等待我找到您的本機JavScript代碼,然后嘗試添加此代碼

<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.4.min.js"/>

暫無
暫無

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

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