943,581 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Marked Solved
  • Views: 13106
  • ASP.NET RSS
You are currently viewing page 1 of this multi-page discussion thread
Feb 19th, 2009
0

MessageBox in C#

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 1
Light Poster
sonakrish is offline Offline
34 posts
since Dec 2008
Feb 19th, 2009
0

Re: MessageBox in C#

Hi
You use
ASP.NET Syntax (Toggle Plain Text)
  1. MessageBox.Show("This is a message");
Reputation Points: 10
Solved Threads: 1
Newbie Poster
frank@furnes.nu is offline Offline
12 posts
since Feb 2009
Feb 19th, 2009
0

Re: MessageBox in C#

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.
Reputation Points: 10
Solved Threads: 1
Light Poster
sonakrish is offline Offline
34 posts
since Dec 2008
Feb 19th, 2009
0

Re: MessageBox in C#

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
ASP.NET Syntax (Toggle Plain Text)
  1. System.Windows.Forms.MessageBox.Show("This is a message");
Reputation Points: 10
Solved Threads: 1
Newbie Poster
frank@furnes.nu is offline Offline
12 posts
since Feb 2009
Feb 19th, 2009
0

Re: MessageBox in C#

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:

ASP.NET Syntax (Toggle Plain Text)
  1. Response.Write(@"<script language='javascript'>alert('This is my Message')</script>");
Reputation Points: 16
Solved Threads: 18
Junior Poster
Aneesh_Argent is offline Offline
104 posts
since Dec 2008
Feb 19th, 2009
0

Re: MessageBox in C#

Correct
I assumed this was a windows application
Reputation Points: 10
Solved Threads: 1
Newbie Poster
frank@furnes.nu is offline Offline
12 posts
since Feb 2009
Feb 19th, 2009
0

Re: MessageBox in C#

In ASP.NET with code Behind VB I have used msgbox().
It worked well.
But in C# am gettin into trouble
Reputation Points: 10
Solved Threads: 1
Light Poster
sonakrish is offline Offline
34 posts
since Dec 2008
Feb 19th, 2009
0

Re: MessageBox in C#

Can you send a sample of the code
Reputation Points: 10
Solved Threads: 1
Newbie Poster
frank@furnes.nu is offline Offline
12 posts
since Feb 2009
Feb 19th, 2009
0

Re: MessageBox in C#

In web application we can use MsgBox() (with code behind VB).
Reputation Points: 10
Solved Threads: 1
Light Poster
sonakrish is offline Offline
34 posts
since Dec 2008
Feb 19th, 2009
0

Re: MessageBox in C#

Okai..
This is my sample code for Palindrome checking.
Got a string in textbox 1.

ASP.NET Syntax (Toggle Plain Text)
  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.
Reputation Points: 10
Solved Threads: 1
Light Poster
sonakrish is offline Offline
34 posts
since Dec 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Latitude and longitude conversion
Next Thread in ASP.NET Forum Timeline: Log In Credentials





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC