I am using an ASP button in a DataList control to pop up an AjaxPopupExtender. However the following error is being thrown:
Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Object reference not set to an instance of an object.
Markup:
<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>
Code-Behind:
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();
}
}