如何在没有Ajax的ASP.NET 2.0中在执行C#代码的过程中打开showModalDialog
how to open showModalDialog in the middle of the C# code execution in ASP.NET 2.0 without Ajax
我必须在C#代码执行的中间打开showModalDialog,并根据条件继续代码
代码如下
protected void Button_Click(object sender, EventArgs e)
{
//some code execution
.
.
.
// need to open showModalDialog with yes & no button and wait for the click
string popupMessage = "<script language='javascript'>showmodal();</script>";
ClientScript.RegisterClientScriptBlock(this.GetType(), "pop", popupMessage);
if (yes)
{
// some code
}
else if (no)
{
// some code
}
} // End of Button click
请帮助我如何在没有Ajax 的情况下使用JavaScript
您应该调用ajax来实现此功能。
前任。
使用jquery的AJAX请求:
$.ajax(){
url: url,
success:function(response){
if(response.status === true)
//open modal
else
//some code
}}
使用javascript:的AJAX请求
function get(url) {
// Return a new promise.
return new Promise(function(resolve, reject) {
// Do the usual XHR stuff
var req = new XMLHttpRequest();
req.open('GET', url);
req.onload = function() {
// This is called even on 404 etc
// so check the status
if (req.status == 200) {
// Resolve the promise with the response text
resolve(req.response);
}
else {
// Otherwise reject with the status text
// which will hopefully be a meaningful error
reject(Error(req.statusText));
}
};
// Handle network errors
req.onerror = function() {
reject(Error("Network Error"));
};
// Make the request
req.send();
});
}
相关文章:
- setTimeout函数能否在其前面的代码执行之前激发
- 延迟代码执行,直到下载完成
- 奇怪的javascript代码执行顺序
- 将字符串作为一段 HTML/javascript 代码执行
- 使用AngularJS,如何在视图和控制器同步特定更改后触发代码执行
- onKeyUp 导致代码执行两次
- JQuery:将参数传递给插件以限制代码执行
- JavaScript代码执行时间
- 基本的JavaScript代码执行
- JavascriptCore:从本机代码执行JavaScript定义的回调函数
- 脚本标记的位置会影响代码执行
- 页面脚本未使用 Salesforce Web-to-Lead 代码执行
- GM_xmlhttpRequest 成功回调“onload”未为注入的代码执行
- 停止所有代码执行,直到 IFrame 完全加载
- 纯 Javascript 代码执行停止混合应用程序中的离子加载指示器
- Javascript代码执行顺序
- Javascript:在嵌套函数中使用条件语句停止代码执行
- Node.js代码执行顺序
- 什么触发JavaScript代码执行
- onreadystatechange导致php代码执行两次