Welcome to Dream.In.Code
Become an Expert!

Join 150,406 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 931 people online right now. Registration is fast and FREE... Join Now!




How to create a MessageBox class for Asp.Net

 
Reply to this topicStart new topic

How to create a MessageBox class for Asp.Net

ScepterMT
23 Mar, 2008 - 11:25 AM
Post #1

New D.I.C Head
*

Joined: 21 Mar, 2008
Posts: 1


My Contributions
When I began the programming for http://www.sceptermarkeingtechnologies.com, I quickly noticed that Asp.net does not support the MessageBox class that I was familiar with in windows forms.

Since Asp.net runs on the server it doesn't have access to produce a modal dialog box on the client. However, by using a scripting language that runs in the clients browser a similar construct is available. In javascript the window.alert() function will produce a modal dialog similar to what you would expect from MessageBox in windows forms.

So, I decided to create a static class MessageBox with a static method Show(), which will give you the ablility to to still use the syntax MessageBox.Show("Your Message"); and then convert it into the javascript window.alert("Your Message"); and add the script to the end of the current response stream.

I've written a how to on my blog at: http://sceptermt.blogspot.com/2008/02/how-...class-in-c.html that shows the source code that I used in C# for my web application and details on how it works.

You could also write overloads for the static show() method to allow the class to do a javascript confirm() or a prompt(). I haven't needed that functionality yet so I've just kept it simple.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 07:23PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month