Click here to Skip to main content
14,355,411 members

.NET MessageBox Control

Rate this:
1.43 (5 votes)
Please Sign up or sign in to vote.
1.43 (5 votes)
11 Sep 2006
For displaying Error,Warning or Information Messages in your ASP.NET WebSite

Sample Image - MessageBox.jpg


.NET MessageBox Control Introduction This Control , as the name implies, is meant for Displaying messages in your Web Pages. Though it is a simple Web Control, I hope that this can be a good and simple introduction to Custom Controls.

How it is implemented?

The MessageBox is implemented by means of a Div Tag which is made draggable by means of a simple javaScript snippet. For this it is required to Override the Render Method of the WebControl . Inside the Render we are writing the MessageBox HTML. We have another Private method called SetClientScript which Outputs the required client script to the Page. Since the scripts are too long but so simple I am not gonna explain it here in detail.

How to Use the Control?

The Usage of this control is simple and neat. All you have to do is

  • compile your control project. 
  • open your website and right click anywhere in the toolbox and click choose items and browse for the Control DLL.
  • Your Control will get added to the ToolBox
  • Drop an instance of it to your page , set the Properties like Heading , Message etc and then set the Visible property to true. By default the Visible property is false .
  • The Images folder should contain error.gif,information.gif,warning.gif,close.gif Images.

From the Code Behind Page,

this.MessageBox1.Message = “This is a Message”;
this.MessageBox1.MessageBoxMode = MessageBoxMode.Error;
this.MessageBox.Visible = true;


Heading : Heading for the Message Box

Message :Message to be displayed

MessageBoxMode: The Type of the Message. The allowed values are, Information, Error, Warning

Color: The ForeColor

BackColor: The Background color for the Message Display Area.

HeadingForeColor: The Foreground color of the Heading Area

HeadingBackColor: The Background color of the Heading Area

AutoHide: A Boolean property indicating whether the MessageBox has to be autohided after a specific interval

AutoHideInterval: The interval for the AutoHide Property.

DropShadow: Boolean Property to specify whether to Drop a Shadow for the MessageBox.

ShadowColor: The color of the Shadow.

ShowButtons: Show the OK and MoreInfo Buttons.

IsModal: Specify whether the window is a modal window.

ImageFolder: Specify the Image Folder.

Position: By this Property , you can specify the position where the message box to be displayed.


For the Appropriate behaviour of this control, The Document type of the Page should be
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">


 I know that this is not a great control, but I feel that it may help some of you guys to get an idea over the Cusom Controls. Please do post your comments and I appreciate if you can provide any tips or suggestions to improve this control.



This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Russell Aboobacker
Web Developer
India India
Russell Aboobacker is a Software Engineer from India, Currently working in Cognizant, Bangalore as Software Architect. He Enjoys Coding and Sharing his Experiences with the Colleagues and Friends.When he is not coding he enjoys spending time with his Family.

If you have any suggestions / Ideas , Share it With me.

Comments and Discussions

GeneralGrid View pagination problem Pin
Laxmi Prakash14-Jan-10 1:51
memberLaxmi Prakash14-Jan-10 1:51 
GeneralExcellent Budy ! Pin
Shafqat Balouchi12-Sep-06 1:48
memberShafqat Balouchi12-Sep-06 1:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Posted 30 Aug 2006


23 bookmarked