Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. displaying an alert in codebehind while using updatepanel control

displaying an alert in codebehind while using updatepanel control

Scheduled Pinned Locked Moved ASP.NET
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sanjubaba
    wrote on last edited by
    #1

    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

    M P A 3 Replies Last reply
    0
    • S sanjubaba

      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

      M Offline
      M Offline
      m dhu
      wrote on last edited by
      #2

      i think this will help you[link]

      1 Reply Last reply
      0
      • S sanjubaba

        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

        P Offline
        P Offline
        Pranay Rana
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • S sanjubaba

          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

          A Offline
          A Offline
          Abhishek Sur
          wrote on last edited by
          #4

          Always use ScriptManager.RegisterStartupScript in case of Update panel rather than using ClientScript. 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

          S 1 Reply Last reply
          0
          • A Abhishek Sur

            Always use ScriptManager.RegisterStartupScript in case of Update panel rather than using ClientScript. 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

            S Offline
            S Offline
            sanjubaba
            wrote on last edited by
            #5

            hi,    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);

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups