how to open showModalDialog in the middle of the C# code execution in ASP.NET 2.0 without Ajax

327 Views Asked by At

I have to open showModalDialog in the middle of the C# code execution and Continue the code depending on the condition

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

1

There are 1 best solutions below

2
Hitesh Modha On

You should make ajax call for implementing this functionality.

ex.

AJAX Request using jquery :

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

AJAX Request using javascript :

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();
  });
}