0

一旦单击按钮,执行操作,我想在后面的代码中显示模式弹出窗口,接下来就是显示模式弹出窗口。我有 modalpopupextender, popup, button 设置为display:none,因此模态弹出窗口不会引发错误。

我在 gridview 中有 imagebutton ,我从中触发后面代码中的动作,一旦执行动作,我希望显示模态弹出窗口。

这就是我所拥有的。标记:

<%@ Page Language="C#" MasterPageFile="~/EmployerMasterPage.master" AutoEventWireup="true"
    CodeFile="JobPostingList.aspx.cs" Inherits="Employer_JobPostingList" ValidateRequest="false" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div id="emplhelp">
        <table cellspacing="0" cellpadding="0" class="cdiv1 border_none">           
            <tr>
                <td valign="top">
                    <table cellpadding="0" cellspacing="0" class="grayborder subtblE">
                        <tr>
                            <td class="pad_grid">
                                <asp:GridView ID="GridView1" class="grdtxt gridvw" runat="server" AutoGenerateColumns="False"
                                    AllowPaging="True" PageSize="20" DataKeyNames="PostingID" BackColor="White" BorderColor="Gray"
                                    BorderStyle="Solid"
                                    Width="100%" BorderWidth="1" CellPadding="3" GridLines="Vertical" EmptyDataText="No Results."
                                    OnDataBound="GridView1_DataBound" OnPageIndexChanging="GridView1_PageIndexChanging">
                                    <Columns>                                                            
                                        <asp:BoundField DataField="Location" HeaderText="Location" />
                                        <asp:BoundField DataField="PostingStatus2" HeaderText="Posting Status" ItemStyle-HorizontalAlign="center" />
                                        <asp:BoundField DataField="DatePosted" HeaderText="Date Posted" DataFormatString="{0:dd/MMM/yyy}"
                                            HtmlEncode="false" ItemStyle-HorizontalAlign="Center" />                                                                                           

                                        <asp:TemplateField HeaderText="Edit" ItemStyle-HorizontalAlign="Center">
                                           <ItemTemplate>                                               
                                               <asp:ImageButton ID="imgButton1" RowIndex='<%# Eval("PostingID") %>' OnClick="imgButton1_Click" runat="server" ImageUrl="/images/a.png" />
                                           </ItemTemplate>
                                                </asp:TemplateField>
                                    </Columns>                           
                                </asp:GridView>

                            </td>
                        </tr>
                        <tr>
                            <td>
                                &nbsp;
                            </td>
                        </tr>                     
                    </table>
                </td>
            </tr>
        </table>
               <asp:Button ID="btnShowPopup" runat="server" style="display:none" />
    </div>
  <!-- LOGIN PANEL -->    
       <asp:Panel ID="pnlConfirm" runat="server" CssClass="modalPanel" Style="display: none; height:160px;">

        <div>
                      <table class="featrEmpDivLoginPopup" style="height:160px; width:460px;" cellspacing="0" cellpadding="0">
                <tr>
                    <td id="divClose" runat="server" class="topimglhs533 hedding1" style="height:30px; background-color:#d3d8d2;">
                        Message 
                    </td>
                </tr>
                <tr>
                    <td>
                        <div id="jsAlert1_popupBody" style="position: absolute; font-family: Verdana,Arial; font-size: 9pt; padding: 2px; text-align: left; background-color: rgb(255, 255, 255); color: black; top: 34px; width: 450px; left: 1px;">
<div style="padding-left:25px; padding-right:25px; padding-top:5px; padding-bottom:5px;">Are you sure you want to Archive this posting?<br></div>
</div>
                    </td>
                </tr>
                          <tr>
    <td style="width:100px; margin-top:5px; padding-left:50px;">
        <asp:ImageButton ID="btnUpdate" ImageUrl="~/Images/btnarchive.jpg" OnClick="btnUpdate_Click" runat="server" />
        <asp:ImageButton ID="btnCancel" ImageUrl="~/Images/cancel.jpg" runat="server" />
        <asp:HiddenField ID="hfPostingID" runat="server" />
</td>
</tr>

            </table>
        </div>
    </asp:Panel>
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btnShowPopup" PopupControlID="pnlConfirm"
CancelControlID="btnCancel" BackgroundCssClass="modalBackground">
</ajaxToolkit:ModalPopupExtender>       
    <!-- LOGIN PANEL -->
</asp:Content>

然后在后面的代码中我有这个:

protected void imgButton1_Click(object sender, ImageClickEventArgs e)
    {
        ImageButton btndetails = sender as ImageButton;
        GridViewRow gvrow = (GridViewRow)btndetails.NamingContainer;
        string postingID = btndetails.Attributes["RowIndex"];
        if (postingID != string.Empty)
        {
            hfPostingID.Value = postingID;
        }
        ModalPopupExtender1.Show();

      //  this.ModalPopupExtender1.Show();

    }

如您所见,我尝试了 this.ModalPopupExtender1 和 ModalPopupExtender 但我得到了相同的响应。

4

1 回答 1

0

不要在我面前有 Visual Studio;但以下内容希望能帮助您朝着正确的方向前进!

替换 ImageButton 标签如下:

<asp:ImageButton ID="imgButton1" commandName="Click" commandArgument='<%# Eval("PostingID") %>' runat="server" ImageUrl="/images/a.png" />

在后面的代码中,使用 gridview 的 RowCommand 事件代替图像按钮的单击事件:

    private sub GridView1_RowCommand(.......) handles ....

    dim xvar=e.commandArgument
    if e.commandName="Click" then
    ...use the **xvar**  to perform custom task before you show the modal popup...
    find the modalPopupControlExtender using FindControl and then use the .SHOW() property
    ...
    ...
    end if

end sub
于 2013-07-07T08:14:07.780 回答