DevNewz News Archives About Us Feedback

Top WebProNews Articles

Working With Fractions In PHP
There are a few ways to display fractions in the web. The most common way is just to add a slash between 2 numbers, like so "1/2".

MySQL's Regular Expression Support
Many months ago I reviewed Ben's MySQL Crash Course, an excellent book that discusses MySQL at a very high, quick to read level.

Use an HttpModule to Spam-proof Your Website
Every time an email address is written on a website, it allows spam robots to collect it and abuse it. If you have a website (e.g. blog or forum) that displays the users e-mail address it would be a nice service to mask it for the...

Web Developers Vs. Traditional Developers on CSS
In the year of 2006 it can be hard to avoid doing web development to some extent no matter what kind of developer you are.

Top AIM Developer Now With Google
Justin Uberti announced Saturday that he has left AOL after nearly 10 years as a lead developer for the company's widely utilized AOL Instant Messenger software.

Countdown to Oracle Open World: OAUG SIG's
If you are heading out to San Francisco for Oracle Open World a bit early and have some free time on Sunday the 22nd, you will want to take advantage of the 5th Annual OAUG Oracle Users Forum being held at the...

Grokking the Source
At archived article, Jeff Atwood has an interesting observation:

PHP Firm Zend Lands $20 Million
Zend develops products for PHP development, and the company just hauled in $20 million in Series D Funding; a "strong candidate" for the open CEO job may be named...

Python Developer Center on Yahoo!
Thanks to Simon Willison, we now have a Python Developer Center on the Yahoo! Developer Network.

Software Development Fallacies to Avoid
In this article I'm going to explain the top 10 software development fallacies my company avoids.

Ajax Book Review
The first thing I should say is that this is a thoroughly enjoyable book. Ed Woychowsky is fun to read, and I could almost recommend this to you even if you have no...

Mac OS X Ruby on Rails - Where to Go Next
When we left off with Mac OS X Ruby on Rails, I had Rails up and running but had not a clue as to where to go from there. It's not hard to find information and tutorials on...

Local Live Makes The Call
Business listings on Microsoft's Windows Live Local search now display a "call for free" link, connecting one's phone...

Shai Agassi on Community Value
Shai Agassi held a private Q&A after his keynote. Of interest to me was his comments on their largest online community, the Software Developer Network:


11.29.06

JavaScript: Alert.Show(”message”) From ASP.NET Code-behind

By Mads Kristensen

In highly interactive websites and intranet sites, you probably want to let the users know what's going on when they delete, save, export etc. on the site.

Those kinds of status messages are widely used and are often implemented by a JavaScript alert box on the web page. ASP.NET doesn't natively support JavaScript functions from the code-behind files. You manually have to print out a script tag and add the alert() call to it.

As easy as it may be, the extensive use of the alert() status message though out a website calls for a unified and simple implementation in order to avoid duplicate code - a centralized method.

In Windows Forms it is very easy to pop up a status message by calling MessageBox.Show("message"). It is that kind of object model we want in ASP.NET for printing out JavaScript alerts. We want Alert.Show("message") in ASP.NET.

Such a thing doesn't exist so we have to create it our selves.

I've written a static class called Alert with one public method called Show. The implementation is as simple as can be. Just put the .cs file in the App_Code folder on your website and you instantly have access to the method from all pages and user controls.

Low Rate eCommerce & Retail Plans



Demonstration

That class of only 30 lines of code enables us to add a JavaScript alert to any page at any time. Here is an example of a Button.Click event handler that uses the method for displaying status messages.



If something was saved without problems, this JavaScript alert box will apear to the user of the website:



Download

Alert.zip (0,57 KB)

Comments


About the Author:
Mads Kristensen currently works as a Senior Developer at Traceworks located in Copenhagen, Denmark. Mads graduated from Copenhagen Technical Academy with a multimedia degree in 2003, but has been a professional developer since 2000. His main focus is on ASP.NET but is responsible for Winforms, Windows- and web services in his daily work as well. A true .NET developer with great passion for the simple solution.

About DevNewz
DevNewz has assembled experts around the world to deliver helpful advice to application developers. Our in-house news staff focuses on keeping you updated with the latest new software and trends in application development. DevNewz provides Knowlege For Application Developers.

DevNewz is brought to you by:

SecurityConfig.com NetworkingFiles.com
NetworkNewz.com WebProASP.com
DatabaseProNews.com SQLProNews.com
ITcertificationNews.com SysAdminNews.com
LinuxProNews.com WirelessProNews.com
CProgrammingTrends.com ITmanagementNews.com


-- DevNewz is an iEntry, Inc. publication --
iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509
2006 iEntry, Inc.  All Rights Reserved  Privacy Policy  Legal

archives | advertising info | news headlines | free newsletters | comments/feedback | submit article
Knowlege For Application Developers DevNewz Home Page About Archive News Downloads WebProWorld Forums Jayde iEntry Advertise Contact