Message box display in ASP.net

HI everyone, its easy to display messages in ASP.NET as in simple c# appln.
Here is the way:

1> Click Solution Explorer
2> Right click on the root ie. C:\...\WebSite5 and choose Add Reference option
3> Choose in .NET tab System.Windows.Forms and click ok. Now the website recognises the component.
4> In the header add

using System.Windows.Forms;

and call it from anywhere within the form like c# application only....

MessageBox.Show("Passwords Doesnt Match", "My Site", MessageBoxButtons.OK, MessageBoxIcon.Error);

njoy :)


Comments

Author: Ultimaterengan23 Jun 2009 Member Level: Gold   Points : 1

Hi friend,

Really good one continue posting such valuable articles

Thanks

Author: Deepika Haridas25 Jun 2009 Member Level: Gold   Points : 1

Hi,

Good article..
an easy solution..

Keep contributing!!!

Regards,
Deepika

Author: Ramesh N D06 Aug 2009 Member Level: Gold   Points : 1

Hi.. this will work Good but have some Restriction. that is message box will appear in minized state.. you have to click the message box in taskbar. so that only it will maxinized..

Author: Hari Nagaraj06 Aug 2009 Member Level: Bronze   Points : 1

Hi...
i too have the same experience in displaying the messagebox...
it will be displayed in the minimized state only.

u can use the Script tag inside the
Response.Write(".... ")
as

Response.Write("script tag")


inside the script tag content must be enclosed in alert for messaging
as
 alert('No more employee to approve!!!!') 


Author: Ramesh N D06 Aug 2009 Member Level: Gold   Points : 1

it will work fine but I hope alert is a java Script. i l provide the code in C#.. Plz wait..

Author: Deepa27 Nov 2009 Member Level: Bronze   Points : 2

In C#:

using System.Windows.Forms

MessageBox.Show("Select a file name ", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Information);

In javascript:

alert('Select a file name');

Client side script write in Server side:

ClientScript.RegisterStartupScript(typeof(string), "Alert", "");

Author: savithri28 Nov 2009 Member Level: Silver   Points : 1

Its Simple yaar!!!!

Dont use any reference
Just write these code where you want Message Box.

Respose.Write("");

""

Author: saurabh n10 Jan 2010 Member Level: Bronze   Points : 2

Display of simple messagebox does not have any alternative other than display alert box from javascript.

You can call javascript from codefile also. Following code is snippest of C# code.

private void Page_Load(object sender, System.EventArgs e)
{
string jScriptValidator;
jScriptValidator= "alert('TextBox cannot be empty')";
Page.RegisterStartupScript("regJSval",jScriptValidator);
}




Otherwise, you can use AJAX modal popup extender with saperate panel to give look & fill of messagebox.

Author: sunil15 Jan 2010 Member Level: Bronze   Points : 2

public void msg(string m)
{

string message = m;

System.Text.StringBuilder sb = new System.Text.StringBuilder();

sb.Append("");

ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString());
}

Author: mausumi16 Jan 2010 Member Level: Gold   Points : 1

hi

it's very easy to use.

keep more postings like this.

4m
mausumi

Author: Jayendra Kumar24 Feb 2010 Member Level: Gold   Points : 1

Really good one. I was searching this since couple of months. I have to use javascript or label to do it. Thanks a lot.

Author: shashi shekhar02 Apr 2010 Member Level: Bronze   Points : 2


Response.Write("