asp.netPRO Try the leading XML editor FREE for 30 days!



Subscription Services
Print Subscription
Online-Only Subscription
Renew Subscription
asp.netNOW Newsletter
Change of Address
Pay An Invoice
Subscription Packages

asp.netPRO
Articles
411asp.net Directory
New Products
Book Reviews
Blog Listings  
E-Newsletter Articles- NEW
Events  - NEW 
Job Listings  
Product Reviews
Opinion
Back Issues
Reprints/E-prints
Search

Downloads
Premium Downloads


Informant
Contact Us
Advertise with Us
Write For Us




 
 
 


US & Europe Data Centers – DiscountASP.NET


MS SQL 2008 on ASP.NET 3.5



2007 asp.netPRO Complete Works CD
Co-Sponsored by:
Download your free trial now!

Click here for the online product directory, asp.netPRO Product Portal

Latest Features

 •

Load Balancing and Scaling Your WCF Services


 •

Got Maps?


 •

The View and the Controller


 •

Take Control


 •

Assess Your Access



Article Rating



Tell a friend
about this article!




UI Tip

LANGUAGES: JavaScript | C#

TECHNOLOGIES: Client Events | Server Controls

 

Hook Client Events to Server Controls

Pick up three quick techniques to fire up server controls from the client side.

 

 

Looking to hook client events to server controls? Well, you can take a variety of approaches. The easiest is when the control doesn't have a server event with the same name. All you need to do is put the client event on the tag:

 

<asp:Image onMouseOver="alert('Mouse Over')" ... />"

 

For objects, as a button, you can hook them to client events by adding attributes from your server-side code. This is some basic code you might add in your page load event:

 

Button1.Attributes.Add("onclick", "alert('Clicked');")

 

If you need to hook up to the form submission, or in the event of validation cases, you can use the RegisterOnSubmitStatement in your server-side code. The following page load code snippet causes any control on the page to display a JavaScript alert box before a submission or postback:

 

RegisterOnSubmitStatement("uniqueKey", "alert('Submit!');")

 

You can use any one of these strategies to call more advanced JavaScript. Using the approach that fits your needs lets you perform more logic on the client side and reduce the overhead of postbacks in ASP.NET.

 

Brad McCabe is the technical evangelist for Infragistics. Brad also has been a systems architect and consultant for Verizon Communications and many other clients, and he was a leading .NET evangelist within Ajilon Consulting. His primary interests include ASP.NET, Windows CE .NET, .NET Compact Framework, and Microsoft's networking technologies. E-mail him at mailto:brad@infragistics.com.

 

 

 

 

Microsoft Internet Explorer
Top of page

Try the leading XML editor FREE for 30 days!


Informant Communications Group

Informant Communications Group, Inc.
5105 Florin Perkins Road
Sacramento, CA 95826
Phone: (916) 379-0609 • Fax: (916) 379-0610

Copyright © 2008 Informant Communications Group. All Rights Reserved. • Site Use Agreement • Send feedback to the Webmaster • Important information about privacy