我正在尝试使用以下代码来获取对 modalpopupextender 的引用,但是当我检查 javascript 变量 'modal' 的值时,它始终为空。使用 javascript 获取对 AJAX 控件的引用的正确方法是什么?
.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"/>