1) Debugging Javascript Code (in aspx file)
Step 1: Make sure that in Browser Advanced options Disable "Script Debugging" option should be unchecked.
Step 2: Write debugger; just before the line you want to debug to start at runtime.
Thats it guys [:)], now run the application and when you will fire the respective event the debugger will act at a breakpoint applied on that page.
2) Getting away from document.getElementById() method
Have you ever thought that you are writing 23 characters everytime, just to get a variable. Now if you have to get 10 variables in one method, you will have to call this method 10 times !! [:(].
Underlying is a suggestion to all of you (including me [:)])
1) Add a .js file in your project
2) Write a method
function $(elementID) { return document.getElementById(elementID);}
3) Use this $ whereever you have written document.getElementById.
e.g. in aspx page javascript function
var ctl = $('inputId');
Note: make sure that the .js file is referenced on that page where you are using this method (this is th only limitation)
Hear you go..... you have optimized your javascript code and replaced 23 letter function with only one character function.
3) To Register a script from Codebehind
Use the following code sample, in Page_Load event:
Monday, March 3, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment