MessageBox in C#

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

Join Date: Dec 2008
Posts: 30
Reputation: sonakrish is an unknown quantity at this point 
Solved Threads: 1
sonakrish sonakrish is offline Offline
Light Poster

MessageBox in C#

 
0
  #1
Feb 19th, 2009
Hiii Alll

I need to display a message to the user after clicking the button control. How to do this in c#.net? I could not find Msgbox() option as we hav in vb.net.

can any one help me
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 12
Reputation: frank@furnes.nu is an unknown quantity at this point 
Solved Threads: 1
frank@furnes.nu frank@furnes.nu is offline Offline
Newbie Poster

Re: MessageBox in C#

 
0
  #2
Feb 19th, 2009
Hi
You use
  1. MessageBox.Show("This is a message");
/Regards
Frank
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 30
Reputation: sonakrish is an unknown quantity at this point 
Solved Threads: 1
sonakrish sonakrish is offline Offline
Light Poster

Re: MessageBox in C#

 
0
  #3
Feb 19th, 2009
Hi.
If I do so Am gettin this error
Error The name 'MessageBox' does not exist in the current context
Do we hav to create a separate function or to use any namespace for this.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 12
Reputation: frank@furnes.nu is an unknown quantity at this point 
Solved Threads: 1
frank@furnes.nu frank@furnes.nu is offline Offline
Newbie Poster

Re: MessageBox in C#

 
0
  #4
Feb 19th, 2009
I guess the Call is done within a Form?
The MessageBox is included in the namespace System.Windows.Forms
Do you have this in your using at the top?
Or have you tried to write
  1. System.Windows.Forms.MessageBox.Show("This is a message");
/Regards
Frank
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 104
Reputation: Aneesh_Argent is an unknown quantity at this point 
Solved Threads: 18
Aneesh_Argent Aneesh_Argent is offline Offline
Junior Poster

Re: MessageBox in C#

 
0
  #5
Feb 19th, 2009
MessageBox is only available in Window Applicaitons. In ASP.NET, you cannot use the MessageBox class or MsgBox function like you can in a Window Applicaitons, but you can emulate this functionality by streaming out a javascript alert instruction like this:

  1. Response.Write(@"<script language='javascript'>alert('This is my Message')</script>");
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 12
Reputation: frank@furnes.nu is an unknown quantity at this point 
Solved Threads: 1
frank@furnes.nu frank@furnes.nu is offline Offline
Newbie Poster

Re: MessageBox in C#

 
0
  #6
Feb 19th, 2009
Correct
I assumed this was a windows application
/Regards
Frank
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 30
Reputation: sonakrish is an unknown quantity at this point 
Solved Threads: 1
sonakrish sonakrish is offline Offline
Light Poster

Re: MessageBox in C#

 
0
  #7
Feb 19th, 2009
In ASP.NET with code Behind VB I have used msgbox().
It worked well.
But in C# am gettin into trouble
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 12
Reputation: frank@furnes.nu is an unknown quantity at this point 
Solved Threads: 1
frank@furnes.nu frank@furnes.nu is offline Offline
Newbie Poster

Re: MessageBox in C#

 
0
  #8
Feb 19th, 2009
Can you send a sample of the code
/Regards
Frank
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 30
Reputation: sonakrish is an unknown quantity at this point 
Solved Threads: 1
sonakrish sonakrish is offline Offline
Light Poster

Re: MessageBox in C#

 
0
  #9
Feb 19th, 2009
In web application we can use MsgBox() (with code behind VB).
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 30
Reputation: sonakrish is an unknown quantity at this point 
Solved Threads: 1
sonakrish sonakrish is offline Offline
Light Poster

Re: MessageBox in C#

 
0
  #10
Feb 19th, 2009
Okai..
This is my sample code for Palindrome checking.
Got a string in textbox 1.

  1. TextBox2.Text = StrReverse(TextBox1.Text)
  2. If TextBox1.Text = TextBox2.Text Then
  3. MsgBox("String is palindrome", MsgBoxStyle.OkOnly)
  4. Else
  5. MsgBox("Not a palindrome", MsgBoxStyle.OkOnly)
  6. End If

This code is done in Asp.Net webapplication with VB code behind.
Can u say how to use message box with C# code behind
Last edited by peter_budo; Feb 19th, 2009 at 4:10 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC