2012-10-08 230 views
0

我在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(); 
    } 
} 

回答

0

我能够通过移动触发此弹出按钮旁边的<li>标记中的标记来解决此问题。

0

你得到有关的JavaScript由于你的AJAX调用,在服务器端异常失败的错误。

为什么不通过在调用服务器时设置断点来调试服务器端代码。通过此活动,您可以准确知道发生异常的位置。

+0

我做的和ajax实例不是null。然而在.Show()这个错误发生。 – Sev

+1

然后mdlComments变量必须为空。这意味着FindControl无法找到ModalPopupExtender控件。你在哪里放置ModalPopupExtender标记? –

相关问题