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 375,219 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,279 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
Views: 3607 | Replies: 4
Reply
Join Date: Mar 2008
Posts: 2
Reputation: ameenu is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
ameenu ameenu is offline Offline
Newbie Poster

message box in c# web application

  #1  
Mar 28th, 2008
how to implement message box in web application using c#
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2007
Posts: 1,054
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: message box in c# web application

  #2  
Mar 28th, 2008
register a script for an "Alert":

  1. string str = "function () { alert('OMG ITS me'); }";
  2.  
  3. Page.RegisterClientScriptBlock("nameofscript", str);
I answer pm's.
I answer questions.
I answer quickly.
I answer.
Reply With Quote  
Join Date: Mar 2008
Posts: 2
Reputation: ameenu is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
ameenu ameenu is offline Offline
Newbie Poster

Re: message box in c# web application

  #3  
Mar 31st, 2008
you have said javascript alert message, but i need server side message using c# code to populate the message box.
Reply With Quote  
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  
Join Date: Feb 2008
Posts: 10
Reputation: vishakha_ate is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
vishakha_ate vishakha_ate is offline Offline
Newbie Poster

Re: message box in c# web application

  #5  
Apr 7th, 2008
if you want to give message box without script than you can insert the snippet of mbox..
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb ASP.NET Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 3:26 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC