Click here to Skip to main content
15,921,212 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to show a confirmation message using client.registerstartupscript in the server side with update panel in asp.net with c# on a button click .

I added a update panel to show a loading gif image using thread.sleep for a longer task. But with it the confirmation message using client.registerstartuoscript server side. Without the update panel it works.

What I have tried:

Code is as below:
#region ShowMessage

      public static void showMessage(string strMessage, Page page)
      {
          try
          {
              Type csType = typeof(String);
              int nKey = 0;
              nKey++;
              string strKey = nKey.ToString();
              string strScript = string.Empty;

              ClientScriptManager clientScript = page.ClientScript;
              if (clientScript.IsStartupScriptRegistered(csType, strKey))
              {
                  nKey++;
                  strKey = nKey.ToString();
              }
              strScript = "<script language = 'javascript'>alert('" + strMessage + "')</script>";
              page.ClientScript.RegisterStartupScript(csType, strKey, strScript);
          }
          catch (Exception ex)
          {
              Common.WriteErrorLog(ex);
          }
      }
      #endregion
Posted
Updated 31-Mar-20 1:29am

1 solution

asp.net - RegisterStartupScript doesn't work with ScriptManager,Updatepanel. Why is that? - Stack Overflow[^]

Users find alert boxes annoying. You're better having a hidden asp:Panel or asp:Placeholder with a message inside (set the Visible property to false), then show the panel\placeholder when you want the user to see the message.
 
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