Show confirmation dialog from the code behind ASP.NET

I want to show confirmation dialog from code.

I have a comfirm A dialog, when I click OK on A, this is a call to method B in the hind code (using ajax post: url / B and B - the method has a webmethod attribute).

In method B I want to show another dialog and the code is flowing: (B - AlertInformLogOut)

[WebMethod]
    public static void AlertInformLogOut(string alertId, string option)
    {           
            //TODO: Open call schedule
            var page = HttpContext.Current.Handler as Page;
            // PopUp alert notify info
            if (page != null)
            {
                page.ClientScript.RegisterStartupScript(page.GetType(), "script", "AlertSetDialog(" + new JavaScriptSerializer().Serialize(new AlertInformEntity()) + ", 'AlertInforms');", true);
                //ScriptManager.RegisterClientScriptBlock(page, page.GetType(), "script", "AlertSetDialog(" + new JavaScriptSerializer().Serialize(new AlertInformEntity()) + ", 'AlertInforms');", true);
            }

    }

      

problem: The dialog is not displayed.

Can anyone tell me why and I can show a dialog from a method with a webmethod attribute.

0


source to share


1 answer


The problem is, as I recall, the WebMethod does not update the page, unlike the ASP: update panel callback.

Since you are using the jQueries ajax function , use a callback instead of trying to do it on the server side.



$.ajax({ 
   type: "POST", 
   url: url+"/UpdateAlertInfo",....,
   success: /*Call you Confirm Function Here */
 }

      

You may want to consider using $. post () instead of

0


source







All Articles