【发布时间】:2014-09-12 15:12:33
【问题描述】:
我正在尝试为用户显示带有确认消息的 AJAX 弹出窗口,但是当用户单击按钮时,会自动转到按钮单击事件而不显示消息。 这就是我所拥有的:
<asp:GridView ID="GridView1" OnRowCommand="GridView1_RowCommand">
<Columns>
<asp:TemplateField ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:ImageButton ID="imgButton1" RowIndex='<%# Eval("PostingID") %>' CommandName="Archive" CommandArgument='<%# Eval("PostingID") %>' runat="server" ImageUrl="/images/a.png" />
<asp:Panel ID="pnlConfirm" runat="server" CssClass="modalPanel" Style="display: none; height:160px; border-color:#B6B6B4;">
<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-top:20px; padding-bottom:5px; text-align:center;">Are you sure you want to Archive this posting?<br></div>
</div>
</td>
</tr>
<tr>
<td style="width:100px; margin-top:5px; text-align:center;">
<asp:ImageButton ID="btnUpdate" CommandName="Archive" ImageUrl="~/Images/btnarchive.jpg" runat="server" />
<asp:ImageButton ID="btnCancel" ImageUrl="~/Images/cancel2.jpg" runat="server" />
</td>
</tr>
</table>
</div>
</asp:Panel>
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="imgButton1" PopupControlID="pnlConfirm"
CancelControlID="btnCancel" BackgroundCssClass="modalBg" DropShadow="false"></ajaxToolkit:ModalPopupExtender>
<!-- PANEL -->
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
所以我希望当用户单击 imgButton1 时会显示弹出窗口,但它会立即在后面的代码中转到事件。
这段代码有什么问题吗?
添加说明
在 Firebug 中,我可以在 ScriptResource.axd 中看到这两个错误:
这可能与我的问题有关吗?
添加了更好的图片:
【问题讨论】:
-
是否将
OnClientCLick="return false;添加到“ImageButton (imgButton1)”帮助中? -
@DennisR 没有回发发生,但也没有显示弹出窗口。谢谢
-
你能给我们展示一些你的imagebutton点击事件的cs代码吗?
标签: c# asp.net gridview asp.net-ajax modalpopupextender