显示警报后调用方法/函数
call a method/Function after alert is shown
这是我打开警报的代码我想要的是,当我按下处于警报状态的"确定"时,我可以调用一个方法/函数。
ClientScriptManager CSM = Page.ClientScript;
string strScript = "<script>";
strScript += "alert('There is no Bookmarked Question Available');";
strScript += " document.getElementById('btnReview').onclick=true";
strScript += "</script>";
ScriptManager.RegisterStartupScript(this, this.GetType(), "Startup", strScript, false);
alert
停止代码的性能,因此一旦关闭alert
将导致以下方法。如果需要确认,请使用 confirm
。
如果我
理解正确,您需要更改代码
,如下所示ClientScriptManager CSM = Page.ClientScript;
string strScript = "<script>";
strScript += "alert('There is no Bookmarked Question Available');";
strScript += " document.getElementById('btnReview').onclick();";
strScript += "</script>";
ScriptManager.RegisterStartupScript(this, this.GetType(), "Startup", strScript, false);
在这种情况下,在警报调用单击后,对于调用方法显示,如果是客户端方法,则如下所示
ClientScriptManager CSM = Page.ClientScript;
string strScript = "<script>";
strScript += "alert('There is no Bookmarked Question Available');";
strScript += " Display();";
strScript += "</script>";
ScriptManager.RegisterStartupScript(this, this.GetType(), "Startup", strScript, false);
我认为当用户按确定时无法执行window.alert
来自 Mozilla API Notes
警报对话框应用于不需要任何消息的消息 用户的响应,除了确认 消息。
对话框是模式窗口 - 它们阻止用户访问 程序界面的其余部分,直到对话框关闭。 因此,不应过度使用任何创建 对话框(或模式窗口)
此外,它不会给出任何结果,例如window.confirm gives true/false
执行函数的任何callback method
。
试试这个:
string strScript = "<script>";
strScript += " if (confirm('There is no Bookmarked Question Available')) { "
strScript += " document.getElementById('btnReview').onclick=true";
strScript += " }"
strScript += "</script>";
创建一个名为"test"的jquery/javascript函数
function test(){
alert('There is no Bookmarked Question Available');
document.getElementById('btnReview').click();
}
现在只需像您正在做的那样从后面的代码中调用此方法:
ScriptManager.RegisterStartupScript(this, this.GetType(), "Startup","test();", true);
就这样
相关文章:
- 你能把一个匿名方法(函数)动态地变成一个命名方法吗
- 显示警报后调用方法/函数
- 使用来自 json 对象的参数动态调用方法/函数
- 创建具有动态参数排列的方法/函数
- 如何从其他 jsp 调用方法/函数以包含在另一个 jsp 的 jstree 中
- Objective-C 方法/函数调用.(来自JavaScript示例)
- 如何在android phongap应用程序中从javascript调用本机android方法(函数),而无需使用web
- 如何测试函数是否调用了特定的方法/函数
- 处理setTimeout(javascript)中的对象方法函数调用
- 简单级别,在DOM中选择元素,优化,创建方法函数
- 在不使用eval的情况下在方法函数中传递固定参数
- jQuery.html()方法函数文字参数
- animate方法函数执行意外延迟
- 对象方法javascript中的方法/函数
- Javascript私有方法:函数表达式与函数声明
- Jquery的oop重写方法函数
- 如何为数组/对象创建方法/函数
- 是否有可能发送我的对象与方法(函数)从服务器到客户端
- Javascript可以调用Django方法/函数吗
- 访问Backbone.js中的Ratchet 2.0方法/函数