message box in c# web application

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2008
Posts: 2
Reputation: ameenu is an unknown quantity at this point 
Solved Threads: 0
ameenu ameenu is offline Offline
Newbie Poster

message box in c# web application

 
0
  #1
Mar 28th, 2008
how to implement message box in web application using c#
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,080
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Solved Threads: 68
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: message box in c# web application

 
0
  #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 Quick reply to this message  
Join Date: Mar 2008
Posts: 2
Reputation: ameenu is an unknown quantity at this point 
Solved Threads: 0
ameenu ameenu is offline Offline
Newbie Poster

Re: message box in c# web application

 
0
  #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 Quick reply to this message  
Join Date: Jun 2006
Posts: 12
Reputation: Hosam Kamel is an unknown quantity at this point 
Solved Threads: 0
Hosam Kamel Hosam Kamel is offline Offline
Newbie Poster

Re: message box in c# web application

 
0
  #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 1:09 pm. Reason: Keep It Organized - please use [code] tags
Thanks,
Hosam Kamel
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 14
Reputation: vishakha_ate is an unknown quantity at this point 
Solved Threads: 0
vishakha_ate vishakha_ate is offline Offline
Newbie Poster

Re: message box in c# web application

 
0
  #5
Apr 7th, 2008
if you want to give message box without script than you can insert the snippet of mbox..
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 6
Reputation: csharpdeveloper is an unknown quantity at this point 
Solved Threads: 0
csharpdeveloper csharpdeveloper is offline Offline
Newbie Poster

Re: message box in c# web application

 
0
  #6
Aug 18th, 2008
how do i use the snippet without the script..
plz. urgent requirement...
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 6
Reputation: csharpdeveloper is an unknown quantity at this point 
Solved Threads: 0
csharpdeveloper csharpdeveloper is offline Offline
Newbie Poster

Re: message box in c# web application

 
0
  #7
Aug 18th, 2008
Originally Posted by Hosam Kamel View Post
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. }
Itz giving me this error....

Error 1 The type or namespace name 'Alert' could not be found (are you missing a using directive or an assembly reference?)

plz. help urgent...
thanx
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 12
Reputation: bheeks is an unknown quantity at this point 
Solved Threads: 1
bheeks bheeks is offline Offline
Newbie Poster

Re: message box in c# web application

 
0
  #8
Aug 19th, 2008
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for ASP.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC