ASP.NET AJAX Shorthand Syntax

by JoeStagner 8/16/2007 7:34:56 AM

Did you know that ASP.NET AJAX include these shorthand notations for commonly used commands ?

$

get('YourControlName')

Shortcut to Sys.UI.DomElement.getElementById - gets a reference to the DOM element, same as document.getElementById

$find(

) 

Shortcut to Sys.Application.findComponent

$create() 

Shortcut to Sys.Application.Component.create

$addHandler(FormElement, EventName, HandlerMethod) 

Shortcut to Sys.UI.DomEvent.addHandler

 $clearHandlers(FormElement) 

Shortcut to Sys.UI.DomEvent.clearHandlers

 $removeHandler(FormElement) 

Shortcut to Sys.UI.DomEvent.removeHandler

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Related posts

Comments

8/16/2007 10:19:24 AM

A very nice blog post by Joe Stagner on the existing ASP.NET 2.0 AJAX Shortcuts can be reached here:

Bilal Haidar [MVP, MCT]

8/16/2007 8:56:10 PM

belle astuce que tu nous fournis Joe sur son blog joeon.net/.../ASP.NET-AJAX-Shorthand-Syntax.aspx

David Verriere

8/16/2007 10:57:41 PM

belle astuce que nous donne Joe sur son blog joeon.net/.../ASP.NET-AJAX-Shorthand-Syntax.aspx

David Verriere

8/17/2007 2:27:37 AM

Shouldn't removeHandler have the same arguments as addHandler?

jon

8/17/2007 4:35:42 AM

i use those religiously in my JS.

even better is that i create my own at the top of my aspx page or in a common.js file at the top

i.e.


$$addCss(e,css){
return Sys.UI.DomElement.addCssClass(e,css);
}

$$removeCss(e,css){
return Sys.UI.DomElement.removeCssClass(e,css);
}

i have a few more. you can of course do a lot more with your imagination ...

joey

8/18/2007 4:20:26 AM

I did know that. What I want to know is what is going on with the development since the 1.0 release? If Microsoft wants to keep up with jQuery, YUI, Ext and all the others they really need to get going.

Mike

8/19/2007 6:22:42 AM

Though it's great to have these shortcuts, it would be great to alias more functions in the Sys namespace, as I'm not sure about you, but I hate writing Sys.UI.DomElement.addCssClass($get('someElement'), 'foo'). It's way too verbose. I much prefer using external libraries, such as mootools, who extend the native DOM elements with functions, such as addClass('foo'). This way, you can just do $get('someElement).addClass('foo'), or if you were to stick entirely with their shortcuts, $('someElement').addClass('foo').

steve

8/21/2007 4:16:40 AM

How do you use these commands?

Partha

8/21/2007 5:00:43 PM

Hi Joe,

What is the requirement to use that shorthand?

Do we need to put ScriptManager first before using those shortcut?

how about if we use those shortcut in the <head> section before we declare it in the <body> ?

Thanks in advance

Kurniawan

8/24/2007 2:09:41 PM

Hi Joe,

AJAX is very powerful after having a look the HDI-AJAX.
but sometimes, I really worried about that if clinetside js is disabled, how can we make it beautifully display without any big problem of viewing the content just losing the effect.
eg. TabControl is missing if js is disabled.

ldsenow

Powered by BlogEngine.NET 1.3.0.0
Theme by Mads Kristensen

About your host.

Name of author Joe Stagner
?????

E-mail me Send mail

Calendar

<<  October 2008  >>
MoTuWeThFrSaSu
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

View posts in large calendar

Pages

Recent comments

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

Sign in