开发者

Issue with Document.Ready, Sys.Application, and FireFox in a ASP.NET Custom Server Control

After searching for a few days I had yet to find a solution to the following issue.

I am creating ASP.NET Custom Server controls that use both AJAX and JQuery within them. Initially creating them in IE I found out pretty quickly that I wanted to use the following within my JavaScript, which is embedded in my server control.

$(document).ready(function () {
    Sys.Application.add_load(function () {

To make sure the page is loaded, and ajax can be used correctly within the control. This has been working great in IE but when I went to do some testing in FireFox the code would fail silently at the Sys.Application.add_load. In looking up solutions I found people suggested to use the pageLoad() method but this won't work when you are creating Custom Server controls since you will have more than one on a page, and don't want to overwrite the pages pageLoad() method.

Nothing else has seem to work.

开发者_高级运维

OK, I have found a solution after 3 days of googling. The following works:

if (Sys) 
    Sys.Application.add_load(initfunc); 
else
   $(document).ready(initfunc);

function initfunc() {

I have tested it in my controls in both IE and FireFox and works great, including when Ajax calls are directly called.

Hope this helps others.


I ended up answering my question above. But this is a more consise place to find the answer for others hopefully.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜