简体   繁体   中英

Show confirm dialog from code behind ASP.NET

I want to show confirm dialog from code be hind.

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

In method BI want to show other dialog, and code is flowing:(B is 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 is: Dialog not showing.

Can some body tell me why, and can I showing dialog from a method has webmethod attribute.

The problem is, as I recall, a WebMethod wont update the page, unlike an ASP:update panel call back.

As you are using jQueries ajax function, use the success call back there, instead of trying to do it server side.

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

You may alss want to consider using $.post() insteado

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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