简体   繁体   English

如何在不使用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

I have to open showModalDialog in the middle of the C# code execution and Continue the code depending on the condition 我必须在C#代码执行的中间打开showModalDialog并根据情况继续执行代码

The code will be like below 代码如下

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

Please help me how to do in JavaScript without Ajax 请帮助我如何在不使用Ajax的JavaScript中进行操作

You should make ajax call for implementing this functionality. 您应该进行ajax调用以实现此功能。

ex. 恩。

AJAX Request using jquery : 使用jquery的AJAX请求:

$.ajax(){
url: url,
success:function(response){
if(response.status === true)
//open modal
else
//some code
}}

AJAX Request using javascript : 使用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();
  });
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM