开发者

Which events do I hook to to initialize javascript using ASP.NET and Telerik's Ajax rad controls?

I'm trying to do some client-side initialization that involves calling $find() on the ClientID of some RadComboBoxes.

My code is being run from an event-handler hooked to window load:

Sys.UI.DomEvent.addHandler(window, 'load',
    function()
    {
        // My initialization stuff
    }
);

Within this code, $find(clientid) returns null.

If I move my initialization code to a window.setTimeout(), $find() works fine. So clearly the only problem is that the client-side code hasn't been initialized, when the window load handler executes.

When I browse the Telerik forums, I see recommendations to put the initialization code in a pageLoad(). Given the organization of the code in this project, that's not possible. (There can only be one pageLoad() function on a page - we have separate initialization functions for multiple user controls that may be included on a single page. We'd like开发者_开发问答 to keep the initialization for each encapsulated inside the control, we don't want to pull all the initialization into a single page-level function.)

Are there any of the standard events that we can catch with Sys.UI.DomEvent to which we can add handlers that will fire after the telerik controls have been initialized?


How about using Sys.Application.add_load()?.


You can have a few handlers for the pageLoaded event. Just place right after the ScriptManager tag script below:

<script type="text/javascript">
    Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(pageLoadedHandler1);

    function pageLoad() {
        Sys.Debug.trace("in pageLoad");
    }

    function pageLoadedHandler1(sender, args) {
        Sys.Debug.trace("in pageLoadedHandler1");
    }
</script>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜