我无法正确使用以下代码。我已经读过,我们必须将上下文保存到变量中,但我找不到一个有效的例子。
我有一个按钮:
按键代码:
<asp:Button ID="Save_BTN" runat="server" Text="Save" OnClientClick="ShowDialog()" OnClick="Save_BTN_Click" Width="48px" />
function ShowDialog() {
$(".selector").dialog({
modal: true,
autoOpen: false,
resizable: false,
width: '450',
position: 'top',
dialogClass: 'no-close'
});
$('.selector').dialog('open');
$('#wait').css('display', '');
}
/////////////////////
protected void Save_BTN_Click(object sender, EventArgs e)
{
if(OK)
{
ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(string), "Script", "UpdateHelloWithNewKEY('" + BusinessUnit["gr_encryptionkey"].ToString() + "')", true);
}
}
//////////////////////
function Update(OldEncryptedHello) {
If(OK)
{ // Do Update work}
}
else
{
alert("Invalid Old KEY.");
$(".selector").dialog("close"); // Error on this line
}
但是我收到了以下错误:
Error: cannot call methods on dialog prior to initialization; attempted to call method 'close'