I always thought writing a simple diagnostic message in a message box would
be pretty simple. Not in .NET.
First, I wrote this amazingly complex piece of code:
MessageBox.Show("yer mama")
It wouldn't even complile. "Gee...", I mused. "Maybe there's no reference
to that method in my project". I muzed correctly. So I added a reference
to System.Windows.Forms, which is where our beloved "MessageBox" method
resides.
Nothing. So at the top of my file, I wrote:
Imports System.Windows.Forms
Still, it wouldn't compile. Finally, I prefixed my call to MessageBox like
this:
System.Windows.Forms.MessageBox.Show("yer mama")
It compiles now, but I never see "yer mama" anywhere on the screen. It's
inside this function:
Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
DropDownList1.SelectedIndexChanged
System.Windows.Forms.MessageBox.Show("Yer mama")
End Sub
Maybe it's just not firing this sub, but that's kinda why the diagnostic is
there. I wanna find out if it is. Does this really have to be so
complicated?
I've run into situations in the past where I've had to spell out simple
methods by fully qualifying their namespaces. Why is that? Shouldn't it be
enough that they're listed under "references" in the solution explorer? Or
even written manually at the top of the file?
Any insights you can give me would be greatly appreciated. 5 1325
Hi
try
msgbox("Hello")
:)
"Curt Emich" <ce****@comcast.net> wrote in message
news:QO********************@comcast.com... I always thought writing a simple diagnostic message in a message box
would be pretty simple. Not in .NET.
First, I wrote this amazingly complex piece of code:
MessageBox.Show("yer mama")
It wouldn't even complile. "Gee...", I mused. "Maybe there's no
reference to that method in my project". I muzed correctly. So I added a reference to System.Windows.Forms, which is where our beloved "MessageBox" method resides.
Nothing. So at the top of my file, I wrote:
Imports System.Windows.Forms
Still, it wouldn't compile. Finally, I prefixed my call to MessageBox
like this:
System.Windows.Forms.MessageBox.Show("yer mama")
It compiles now, but I never see "yer mama" anywhere on the screen. It's inside this function:
Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
System.Windows.Forms.MessageBox.Show("Yer mama")
End Sub Maybe it's just not firing this sub, but that's kinda why the diagnostic
is there. I wanna find out if it is. Does this really have to be so complicated?
I've run into situations in the past where I've had to spell out simple methods by fully qualifying their namespaces. Why is that? Shouldn't it
be enough that they're listed under "references" in the solution explorer?
Or even written manually at the top of the file?
Any insights you can give me would be greatly appreciated.
"Curt Emich" <ce****@comcast.net> wrote in message
news:QO********************@comcast.com... It wouldn't even complile. "Gee...", I mused. "Maybe there's no
reference to that method in my project". I muzed correctly. So I added a reference to System.Windows.Forms, which is where our beloved "MessageBox" method resides.
Nothing. So at the top of my file, I wrote:
Imports System.Windows.Forms
Still, it wouldn't compile. Finally, I prefixed my call to MessageBox
like this:
It should. What compiler error message did it give you? That should be
enough.
Maybe it's just not firing this sub, but that's kinda why the diagnostic
is there. I wanna find out if it is. Does this really have to be so complicated?
If you want to tell if the event handler is being executed, a breakpoint
would probably be better. Also, you might want to think about the
Debug.Write and Debug.WriteLine methods, in the System.Diagnostics
namespace. You don't have to add any extra references for those, and the
namespace is imported at the project level by default. Just make sure
you're targeting a Debug build.
I've run into situations in the past where I've had to spell out simple methods by fully qualifying their namespaces. Why is that? Shouldn't it
be enough that they're listed under "references" in the solution explorer?
There are a lot of namespaces, and some of them have identical class
names. If everything was automatically imported, it would clog up the IDE
and lead to a lot of ambiguity. Odds are your code would have to use the
fully-qualified name -more- that way.
Jeremy
----- Curt Emich wrote: ----
... I added a reference to System.Windows.Forms, which is where our beloved "MessageBox" metho
resides
MessageBox is not a method; it's a class
...at the top of my file, I wrote
Imports System.Windows.Form
Still, it wouldn't compile. Finally, I prefixed my call to MessageBox lik
this
System.Windows.Forms.MessageBox.Show("yer mama"
What was the text of the error message? If you added the reference and the Imports statement, this line should compile just fine
...Maybe it's just not firing this sub, but that's kinda why the diagnostic i
there.
Is the control declared WithEvents? If not, you'l have to manually attach the event handler
AddHandler DropDownList1.SelectedIndexChanged, AddressOf DropDownList_SelectedIndexChange
...Does this really have to be so complicated
Well, yes. There are many dlls included with the framework, and any number may be added by a third party. They can't all be reference by default, otherwise you'd have multi-megabyte apps for even the most trivial of tasks.
...I've run into situations in the past where I've had to spell out simpl
methods by fully qualifying their namespaces. Why is that? Shouldn't it b
enough that they're listed under "references" in the solution explorer
All namespaces imported by default would be the same as not having namepaces at all. Everything would have to be fully qualified
As the namespace implies, the MessageBox method is for windows forms
applications.
In an ASP.NET environment your client is a web browser, therefore you should
use client side code such as javascript to display a message box on the
client.
Execute a line of code like this when you want a message box to be
displayed.
(This writes out the necessary client side javascript to your HTML page to
make the alert pop up as soon as the page is sent to their browser.)
RegisterStartupScript("startupScript", "<script
language=JavaScript>alert('This is my message.');</script>");
Here's more info: http://msdn.microsoft.com/library/de...criptTopic.asp
Here are a couple controls you might find to be useful: http://www.metabuilders.com/Tools/ConfirmedButtons.aspx http://www.jttz.com/msgbox/index.htm
--
I hope this helps,
Steve C. Orr, MCSD, MVP http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com
"Curt Emich" <ce****@comcast.net> wrote in message
news:QO********************@comcast.com... I always thought writing a simple diagnostic message in a message box
would be pretty simple. Not in .NET.
First, I wrote this amazingly complex piece of code:
MessageBox.Show("yer mama")
It wouldn't even complile. "Gee...", I mused. "Maybe there's no
reference to that method in my project". I muzed correctly. So I added a reference to System.Windows.Forms, which is where our beloved "MessageBox" method resides.
Nothing. So at the top of my file, I wrote:
Imports System.Windows.Forms
Still, it wouldn't compile. Finally, I prefixed my call to MessageBox
like this:
System.Windows.Forms.MessageBox.Show("yer mama")
It compiles now, but I never see "yer mama" anywhere on the screen. It's inside this function:
Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
System.Windows.Forms.MessageBox.Show("Yer mama")
End Sub Maybe it's just not firing this sub, but that's kinda why the diagnostic
is there. I wanna find out if it is. Does this really have to be so complicated?
I've run into situations in the past where I've had to spell out simple methods by fully qualifying their namespaces. Why is that? Shouldn't it
be enough that they're listed under "references" in the solution explorer?
Or even written manually at the top of the file?
Any insights you can give me would be greatly appreciated.
Hi Steve,
I think that I would not have seen this, however I look to it from the
languages.vb group, when it was in the aspnet group, I would have seen.
I message this to point the OP hat this message is in my opinion the right
one, there are so much which are for the windowform, that he can become
confused.
And have nothing to add.
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mystery Man |
last post by:
We have developed a CSharp program that has a secondary thread that is
used to perform background operations. This secondary thread may
display some MessageBoxes or Forms.
However, if the...
|
by: Bill |
last post by:
For some reason, I have an errormessage popup that "blinks", but pops up
BEHIND the applications, which is confusing to users.
Is there any way to force it to the top?
|
by: Curt Emich |
last post by:
I always thought writing a simple diagnostic message in a message box would
be pretty simple. Not in .NET.
First, I wrote this amazingly complex piece of code:
MessageBox.Show("yer mama")
...
|
by: tma |
last post by:
How are message boxes (not the browser pop-up variety but rather the .NET
msgbox) achieved in ASP.NET?
|
by: harvie wang |
last post by:
Hi,
I want to add more buttons to messagebox, such as "Apply All".
Can i implement a custom messagebox, inherite from System.Windows.Form.MessageBox?
Best wish,
harvie
2006-1-18
|
by: randy1200 |
last post by:
I have the following line of C# code:
MessageBox.Show(filesThatDoNotExist, "Files Not Found", MessageBoxButtons.OK);
This line generates the following warning when I select "Run Code Analysis"...
|
by: Goran Djuranovic |
last post by:
Hi all,
I have a VB.NET windows application that uses MDI form. When I try to delete a datagrid row from one of the MDI children forms, I use a MessageBox YesNo confirmation, which, after confirmed,...
|
by: =?Utf-8?B?ZGxpbmdn?= |
last post by:
I have a simple c# windows form with a textbox and button that, when clicked,
displays a simple MessageBox.
With the cursor in the textbox, I can select the Japanese language and
desired Input...
|
by: Frank Rizzo |
last post by:
I am trying to programmatically close a messagebox. I don't see any
obvious managed choices. Back in the day, I remember using a
combination of FindWindow and EndDialog apis(...
|
by: Curious |
last post by:
Hi,
I used MessageBox.Show method to show message boxes to alert about
issues.
However, it seems that they're always minimized at the bottom of the
screen. Is there anyway I can make them...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |