我想使用下面的代碼來獲取對modalpopupextender的引用,但是當我檢查javascript變量'modal'的值時,它始終爲空。使用javascript獲得對AJAX控件的引用的正確方法是什麼?使用javascript無法獲取對ModalPopupExtender的引用
的.vb
Dim myStringBuilder As New StringBuilder(246)
myStringBuilder.AppendFormat(" <script type=""text/javascript"">{0}", Environment.NewLine)
myStringBuilder.AppendFormat(" var modal = $find('<%=modal1.ClientID%>');{0}", Environment.NewLine)
myStringBuilder.AppendFormat(" debugger;{0}", Environment.NewLine)
myStringBuilder.AppendFormat(" $find('<%=modal1.ClientID%>').add_showing({0}", Environment.NewLine)
myStringBuilder.AppendFormat(" function(){0}", Environment.NewLine)
myStringBuilder.AppendFormat(" {{{0}", Environment.NewLine)
myStringBuilder.AppendFormat(" alert(""Modal popup will be showing"");{0}", Environment.NewLine)
myStringBuilder.AppendFormat(" }}{0}", Environment.NewLine)
myStringBuilder.AppendFormat(" );{0}", Environment.NewLine)
myStringBuilder.AppendFormat(" </script>{0}", Environment.NewLine)
ClientScript.RegisterStartupScript(Me.GetType(), "myJSalert", myStringBuilder.ToString())
的.aspx
<ajaxToolkit:ModalPopupExtender ID="mpeResetConfirm" runat="server"
TargetControlID="btnReset" PopupControlID="pnlConfirmation" BehaviorID="modal1"/>
我得到這個錯誤:「空」爲空或不是一個對象 – swolff1978 2009-06-15 16:27:03
你與你的擴展的ID替換「IDofModalPopupExtender」?另外,你從哪裏得到'null'? – 2009-06-15 16:31:46