This is a migrated thread and some comments may be shown as answers.

Can't get RadAjaxManager onload when not localhost

1 Answer 70 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Nick
Top achievements
Rank 1
Nick asked on 01 Apr 2011, 01:19 AM
Hello,

Let me try to explain the subject. I have a page with RadAjaxManager and need to get hold of it when application initially loads. I am doing it like that:
var ajaxManager = $find("<%= RadAjaxManager.GetCurrent(this).ClientID %>");

 problem is that it works fine when I open page in localhost, like http://localhost. However, when I change localhost to something else (like http://sameMachine), it can't get it and returns null.

Here is sample page:
<html lang="en">
<head id="Head1" runat="server">
    <meta charset="utf-8" />
    <title>Blah</title>
</head>
<body>
    <form id="form1" class="form" runat="server">
    <telerik:RadScriptManager ID="ScriptManager" runat="server" EnablePageMethods="True"
        EnableTheming="True">
    </telerik:RadScriptManager>
    <div id="Div1" class="page" runat="server">
            <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel" runat="server" Skin="Sitefinity" />
            <telerik:RadAjaxManager ID="RadAjaxManager" runat="server">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="testButton">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="testButton" UpdatePanelHeight="" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>
          <asp:Button ID="testButton" runat="server" Text="Test Me" OnClientClick="TestMe('button');" />
    </div>
    <script type="text/javascript">
        function TestMe(argument) {
            var ajaxManager = $find("<%= RadAjaxManager.GetCurrent(this).ClientID %>");
            if (ajaxManager == null) {
                alert('NULL. called by ' + argument);
            }
            else {
                alert('Got it from ' + argument);
            }
        }
 
        window.attachEvent("onload", function () {
           // will work fine if run on localhost
            TestMe('window.onload');
        });
 
       
    </script>
    </form>
</body>
</html>

Please advise.

Thanks,
Nick

1 Answer, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 04 Apr 2011, 01:41 PM
Hi Nick,
 The window.onload event is fired too early. At that point the client object of the manager is not created yet. You can handle the pageLoad event instead. Find more information in this blog post.

Best wishes,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Ajax
Asked by
Nick
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Share this question
or