开发者

Best practices in using Javascript in ASP.NET in a pre-AJAX and pre-jQuery era

I would like to know what are the best practices in using Javascript in ASP.NET in a pre-AJAX and pre-jQuery era. What I meant by pre-era is not the time before AJAX/jQuery was created, but rather the time before it is popularized and widely adopted (by a significantly large number of programmers).

i.e. Is it good thing to store the script in a st开发者_JS百科ring variable and register it on demand (RegisterClientScriptBlock) or on startup (RegisterStartUpScript)?

Although I would be happy to see answers in using Javascript in ASP.NET, its usage in PHP and JSP are also welcome.

Thanks in advance for your time and expertise.


I have always been an opponent of the RegisterClientScriptBlock methods and object structure. When you use these methods, your JavaScript is injected into the page at the behest of the page controls. This means it could end up being output in very specific positions and not necessarily in the order desired.

My JavaScript methods are always external to the page, typically in a separate file. When needed I use a literal control to output JavaScript assignment objects (to let the scripts know what any pertinent ClientIDs might be for accessing fields.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜