我在 DataList 控件中使用 ASP 按钮来弹出 AjaxPopupExtender。但是会引发以下错误:
Microsoft JScript 运行时错误:Sys.WebForms.PageRequestManagerServerErrorException:对象引用未设置为对象的实例。
标记:
<asp:HiddenField ID="ModalPopUpHidden" runat="server" />
<cc1:ModalPopupExtender ID="mdlComments" runat="server"
CancelControlID="btnCancelComment" PopupControlID="pnlComments"
TargetControlID="ModalPopUpHidden" PopupDragHandleControlID="PopupHeader"
Drag="true" BackgroundCssClass="ModalPopupBG">
</cc1:ModalPopupExtender>
<asp:Panel ID="pnlComments" Style="display: none" runat="server">
<div class="popup_Container">
<div class="popup_Titlebar" id="PopupHeader">
Comment
</div>
<div class="popup_Body">
<asp:TextBox ID="txtPopupComment" runat="server" MaxLength="500"
TextMode="MultiLine" Width="200" Height="200">
</asp:TextBox>
</div>
<div class="popup_Buttons">
<asp:Button id="btnSaveComment" type="button" value="Save"
runat="server" Text="Save" CommandName="SaveComment" />
<input id="btnCancelComment" type="button" value="Cancel"/>
</div>
</div>
</asp:Panel>
代码隐藏:
protected void dtListBids_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName == "Comments")
{
AjaxControlToolkit.ModalPopupExtender mdlComments =
(AjaxControlToolkit.ModalPopupExtender)e.Item.FindControl("mdlComments");
BidId = Convert.ToInt64(dtListBids.DataKeys[0]);
mdlComments.Show();
}
}