displaying an alert in codebehind while using updatepanel control
-
Hi, i am inheriting a masterpage in an aspx page. in the masterpage i am using updatepanel control. now in the codebehind of that aspx page, when i complete the databasetransaction process, i want to display an alert box. But that alert box is not getting displayed as i am using updatepanel control. prior to using updatepanelcontrol it was working as i use to display the alert box using httpcontext.current.response.write. now as i am using updatepanelcontrol the alert box is not getting displayed by using registerscriptblock also.
Sandeep Kumbhar
-
Hi, i am inheriting a masterpage in an aspx page. in the masterpage i am using updatepanel control. now in the codebehind of that aspx page, when i complete the databasetransaction process, i want to display an alert box. But that alert box is not getting displayed as i am using updatepanel control. prior to using updatepanelcontrol it was working as i use to display the alert box using httpcontext.current.response.write. now as i am using updatepanelcontrol the alert box is not getting displayed by using registerscriptblock also.
Sandeep Kumbhar
-
Hi, i am inheriting a masterpage in an aspx page. in the masterpage i am using updatepanel control. now in the codebehind of that aspx page, when i complete the databasetransaction process, i want to display an alert box. But that alert box is not getting displayed as i am using updatepanel control. prior to using updatepanelcontrol it was working as i use to display the alert box using httpcontext.current.response.write. now as i am using updatepanelcontrol the alert box is not getting displayed by using registerscriptblock also.
Sandeep Kumbhar
Handle end request event of the update panel as following will may help you 1. Get instance of PageRequestManager Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandler); 2. Callback function: function endRequestHandler(sender, eventArgs) { if (eventArgs.get_error() != undefined && eventArgs.get_error().httpStatusCode == '500') { var error Message = eventArgs.get_error().message; eventArgs.set_errorHandler(true); alert(errorMessage); } else { //alert($get("hidField").value); } }
-
Hi, i am inheriting a masterpage in an aspx page. in the masterpage i am using updatepanel control. now in the codebehind of that aspx page, when i complete the databasetransaction process, i want to display an alert box. But that alert box is not getting displayed as i am using updatepanel control. prior to using updatepanelcontrol it was working as i use to display the alert box using httpcontext.current.response.write. now as i am using updatepanelcontrol the alert box is not getting displayed by using registerscriptblock also.
Sandeep Kumbhar
Always use
ScriptManager.RegisterStartupScript
in case of Update panel rather than usingClientScript
. do like this :ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('hi');", true);
:thumbsup:
Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Windows7 API Code Pack
Simplify Code Using NDepend
Basics of Bing Search API using .NET -
Always use
ScriptManager.RegisterStartupScript
in case of Update panel rather than usingClientScript
. do like this :ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('hi');", true);
:thumbsup:
Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Windows7 API Code Pack
Simplify Code Using NDepend
Basics of Bing Search API using .NEThi, indeed this was a very good solution. now i making this thing generic. so that i only have to call the msgpopup class and display the message. i am calling the dll of the project where i am writing the same code ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('hi');", true); but this seems to be not working. it fails to display the message box. following is the code in the dll. the code:-- ========== using System; using System.Data; using System.Configuration; using System.Web; using System.Collections; using System.Text; using System.Web.UI; /// <summary> /// Summary description for MsgPopUp /// </summary> public class MsgPopUp { protected static Hashtable handlerPages = new Hashtable(); public static void Show(string Message) { try { if (!(handlerPages.Contains(HttpContext.Current.Handler))) { Page currentPage = (Page)HttpContext.Current.Handler; if (!((currentPage == null))) { Queue messageQueue = new Queue(); messageQueue.Enqueue(Message); handlerPages.Add(HttpContext.Current.Handler, messageQueue);