Click here to Skip to main content
15,923,120 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have an ajax method that I want to show a popup message on successful completion. If we call another ajax method on success, the message is not shown. Does anybody have any ideas how to show the popup?

JavaScript
function OnResetClick() {
      var userEmail = document.getElementById("ContentPlaceHolder1_User");
      var val = user.value;
      var r = "";
      var getPassword = {
          type: "POST",
          url: "main.aspx/GetString",
          data: "",
          contentType: "application/json; charset=utf-8",
          dataType: "json",
          success: function (response) {
            r = response.d;
            
            GetMsg(val, r);
          },
          error: function (result) {
            alert("Error in seding mail");
          }
        };
        //Call the PageMethods
        $.ajax(getPassword);
      }

function GetMsg(val, r) {
      if (randomPassword != "") {
        var options = {
          type: "POST",
          url: "main.aspx/GeMessage",
          data: "{'toMailAddress':'" + val + "','r':'" + r + "'}",
          contentType: "application/json; charset=utf-8",
          dataType: "json",
          success: function (response) {
            var val1 = response.d;
            // some times it shows, but mostly this alart 
            // message does not comes
            alert(val1);
          },
          error: function (result) {
            alert("Error in " + result);
          }
        };
        //Call the PageMethods
        $.ajax(options);
      }
    }
Posted
Updated 19-Nov-10 1:37am
v4

Hi,

You can use this jquery plugin
http://yensdesign.com/2008/09/how-to-create-a-stunning-and-smooth-popup-using-jquery/[^]
Or you can choose from any of these below
http://choosedaily.com/1178/15-jquery-popup-modal-dialog-plugins-tutorials/[^]

For the first one I mentioned above, You need to call loadPopup(); this function from server side code after some task is performed and you can use this with update panel also, all you need to do this, if you are using script manager then use this
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "_SHOW_POPUP", "loadPopup();", true);
Or you can use this in case you are not using script manager,
ClientScript.RegisterClientScriptBlock(this, this.GetType(), "_SHOW_POPUP", "loadPopup();", true);

Hope this is will help.

Thanks,
Mark it as Answer if you find it Correct.
 
Share this answer
 
Hi I am giving you a simple javascript from code behind file.

public void ShowPopup(string alertMessage)
{
ScriptManager.RegisterStartupScript(this,GetType(),"alert(alertMessage),true");
}


Call this method and pass the alertMessage to show the popup with this alertMessage.

Warm Regards,
Naresh...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900