User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 427,205 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,135 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting

message box in c# web application

Join Date: Jun 2006
Posts: 12
Reputation: Hosam Kamel is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
Hosam Kamel Hosam Kamel is offline Offline
Newbie Poster

Re: message box in c# web application

  #4  
Apr 4th, 2008
Use the below mehtod

  1. public static void ShowMessageBox(string message)
  2. {
  3. if (!string.IsNullOrEmpty(message))
  4. {
  5. if (message.EndsWith("."))
  6. message = message.Substring(0, message.Length - 1);
  7. }
  8.  
  9. StringBuilder sbScript = new StringBuilder(50);
  10. //Java Script header
  11. sbScript.Append("<script type='text/javascript'>" + Environment.NewLine);
  12. sbScript.Append("// Show messagebox" + Environment.NewLine);
  13. message = message.Replace("\n", "\\n").Replace("\"", "'");
  14. sbScript.Append(@"alert( """ + message + @""" );");
  15. sbScript.Append(@"</script>");
  16. // Gets the executing web page
  17. Page currentPage = HttpContext.Current.CurrentHandler as Page;
  18. // Checks if the handler is a Page and that the script isn't already on the Page
  19. if (currentPage != null && !currentPage.ClientScript.IsStartupScriptRegistered("ShowMessageBox"))
  20. {
  21. currentPage.ClientScript.RegisterStartupScript(typeof(Alert),"ShowMessageBox", sbScript.ToString());
  22. }
  23. }
Last edited by peter_budo : Apr 5th, 2008 at 12:09 pm. Reason: Keep It Organized - please use [code] tags
Thanks,
Hosam Kamel
Reply With Quote  
All times are GMT -4. The time now is 10:55 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC