Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
422 views
in Technique[技术] by (71.8m points)

javascript - AjaxManager not found...null

I have a User Control and a Content Page. In the Content Page, I have a RadDockLayout control inside Update panel like below. I have an Image button, Once user swaps the position of RadDock by Drag Drop. User presses save button to save the order in database.

<asp:updatepanel id="UpdatePanel1" runat="server">
    <ContentTemplate>
        <telerik:RadDockLayout runat="server" OnLoadDockLayout="RadDockLayout1_LoadDockLayout"
            ID="RadDockLayout1" OnSaveDockLayout="RadDockLayout1_SaveDockLayout">

                        <telerik:RadDockZone runat="server" Orientation="Horizontal" ID="HealthZone" Visible="false"
                            BorderStyle="None" Style="margin: 0;">
                        </telerik:RadDockZone>
                        <telerik:RadDockZone runat="server" Orientation="Horizontal" ID="RadDockZone1" BorderStyle="None"
                            Style="margin: 0; width:540px;">
                        </telerik:RadDockZone>
                        <telerik:RadDockZone runat="server" Orientation="Horizontal" ID="AdZone" Visible="false"
                            BorderStyle="None" Style="margin: 0;" Width="324px">
                        </telerik:RadDockZone>

        </telerik:RadDockLayout>

    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="imgsave" EventName="Click" />
    </Triggers>
</asp:updatepanel>

During the save process, I call another function. which is also under User Control.

public void RePopulateOverview(UserControl overviewuc)
{
    RePopulated = true;
    CurrentDockStates.Clear();
    RadAjaxManager AjaxManager = RadAjaxManager.GetCurrent(this.Page);
    AjaxManager.AjaxSettings.Clear();
    AjaxManager.AjaxSettings.AddAjaxSetting(AjaxManager, overviewuc);
    //InitiateAjaxRequest
    RadScriptManager.RegisterStartupScript(this.UpdatePanel1, 
    this.GetType(), "OverviewReLoadScript" + 
    Guid.NewGuid().ToString().Replace("-", "a"), 
    "javascript:InitiateAjaxRequest();", true);
}

and below is the corresponding javaScript Function like below.

<script type="text/javascript">
    function InitiateAjaxRequest() {
        if ($find("<%= Telerik.Web.UI.RadAjaxManager.GetCurrent(this.Page).ClientID %>") != null)
            $find("<%= Telerik.Web.UI.RadAjaxManager.GetCurrent(this.Page).ClientID %>").ajaxRequest();
        else {
            alert("AjaxManager not found..." + $find("<%= Telerik.Web.UI.RadAjaxManager.GetCurrent(this.Page).ClientID %>"));
        }
    } 
</script>

My Issue is When I presses Save Button second time it crashes and Error Message is below.

AjaxManager not found...null

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It should be like this.

var ID;
function InitiateAjaxRequest() {
    if (ID == null) {
        ID = $find("<%= Telerik.Web.UI.RadAjaxManager.GetCurrent(this.Page).ClientID %>");
        ID.ajaxRequest();
    }
    else
        ID.ajaxRequest();
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...