Fun Pet Trick 3: Client-Side Script IntelliSense by Browser Type


Fun Pet Trick #3: Client-Side Script IntelliSense by Browser Type

By Scott Guthrie

VS .NET provides full client-side IntelliSense on pages. To see this in action, just follow these steps:

  1. Create a new page.

  2. Flip to source view.

  3. Click the drop-down list on the top left (default selection is Server Objects & Events).

  4. Select the window object from the drop-down list (it is indented under Client Objects & Events).

  5. From the second drop-down list (to the right of the first one), select the onload event. This will automatically generate a client-side window_load event handler.

  6. Within the window_onload() event handler type document. You should then get full IntelliSense against the document client-side object property.

  7. Now change the validation target of the document by clicking the validation link on the bottom-right side of the window. By default, it is set to IE 6.0. Try clicking it, and then changing it to Netscape Navigator 4.0.

  8. Now go back to the event handler and reenter the "." after the document object—notice that the client-side object model has shrunk. This is because the IntelliSense engine is filtering to only show those methods, events, and properties of the client-side elements that are available with the currently selected validation target. Because Navigator 4.0 has less client JavaScript support than IE 6.0, the IntelliSense list is smaller.

A small touch—but one that makes doing client-side scripting a lot easier, and ensures that the JavaScript you write works with the browsers you target.




ASP. NET 2.0 Revealed
ASP.NET 2.0 Revealed
ISBN: 1590593375
EAN: 2147483647
Year: 2005
Pages: 133

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net