我在DataList控件中使用ASP按鈕彈出AjaxPopupExtender。但是正在拋出以下錯誤:ModalPopupExtender,對象引用未設置爲對象的實例錯誤
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();
}
}
我做的和ajax實例不是null。然而在.Show()這個錯誤發生。 – Sev
然後mdlComments變量必須爲空。這意味着FindControl無法找到ModalPopupExtender控件。你在哪裏放置ModalPopupExtender標記? –