I am currently working on a website which has a lot of javascript . How can i make sure that my javascript has the best chance of running properly? By adding another script section in the page or through asp.net registering the script?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You should read: http://msdn.microsoft.com/en-us/library/aa478975.aspx
By using the RegisterStartupScript() method on the server side Page_Load you can ensure that all of your HTML markup is loaded and ready to be modified. It is also good practice to put your javascript sections at the bottom of your form’s markup if you want to access html elements, for example setting a textboxes text or something.
You can’t really say one is “better” or has a “better chance of running properly” than the other, because you would use either/or depending on what you need to do. If you read the above link that I posted I think things will make a lot more sense for ya.