ukdlf
Mon Nov 10 18:19:22 CST 2003
Try
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWindowsFormsMessageBoxClassTopic.asp
protected void button1_Click(object sender, System.EventArgs e) {
if(textBox1.Text == "") {
MessageBox.Show("You must enter a name.", "Name Entry Error",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
else {
// Code to act on the data entered would go here.
}
}
You may need to change to MessageBoxButtons.OKCancel or YesNoCancel
Alternatively:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsmessageboxclassshowtopic.asp
private void validateUserEntry2()
{
// Checks the value of the text.
if(serverName.Text.Length == 0)
{
// Initializes the variables to pass to the MessageBox.Show
method.
string message = "You did not enter a server name. Cancel this
operation?";
string caption = "No Server Name Specified";
MessageBoxButtons buttons = MessageBoxButtons.YesNo;
DialogResult result;
// Displays the MessageBox.
result = MessageBox.Show(this, message, caption, buttons,
MessageBoxIcon.Question, MessageBoxDefaultButton.Button1,
MessageBoxOptions.RightAlign);
if(result == DialogResult.Yes)
{
// Closes the parent form.
this.Close();
}
}
}
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (
http://www.grisoft.com).
Version: 6.0.537 / Virus Database: 332 - Release Date: 06/11/2003