ASP.Net C# MessageBox

Modal boxes are great to get a users response. Sometimes, they replace the traditional JavaScript alert and confirm dialogs giving the end user a better experience. But managing modal boxes in code can sometimes be tricky. For example, you may have a modal box, that needs to look and behave differently or give the user options based on certain conditions. For this reason I've developed a C# message box class that can render the markup for a modal box based on templates.
The MessageBox class can be used to add a custom modal box to your application. Because it's template based, you can use any existing modal box library. For example you can use Twitters modal box from the bootstrap. The class, allows you to configure the template, allowing you to set the modal box's title, message and buttons . You can even add your own custom variables on the template and use the class to assign it values.

Using this approach means, you can render only the modal box elements you need. Consider this scenario, you have an MVC application, where one view is shared between several actions. Your view has a modal box markup but the modal box, needs to show different options based on which controller action is invoking the view. Using the MessageBox class, you can configure the modal box from the action method and render it on the view.

Below is a list of class methods and properties.


Name Description
Buttons Gets a button collection that represents child button controls.
Message Sets or gets the modals message.
Template Sets or gets the path to the template file.
Title Sets or gets the modals title.
Variable Gets a variable collection that represents user defined key/value variables.
Download For C# Download For VB

1 comment:

Taufik Lukman said...

most useful messagebox for
Thanks for share

Post a Comment