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

[Solved] RadAjaxManager and Javascript after AjaxRequest

4 Answers 459 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Thomas Eberhard
Top achievements
Rank 2
Thomas Eberhard asked on 14 Mar 2008, 09:44 AM
Maybe this has been answered in another thread but after a couple hours of searching I am unable to find the answer...

I have a RadAjaxManager on a page that I would like to cause a postback using the javascript code below

the codebehind gets called (as listed below) but the javascript *never* shows up on the page.

Is there something I should be doing different?

----webpage code----
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadAjaxPanel1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="lblLabel" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>

----code behind----
    Private Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs) Handles RadAjaxManager1.AjaxRequest
        Me.RadAjaxManager1.ResponseScripts.Add("alert('This is an alert');")
    End Sub

----javascript----

    var arguments = '';
var ajaxManager = <%=RadAjaxManager1.ClientID %>;
ajaxManager.AjaxRequest(arguments);


4 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 14 Mar 2008, 10:45 AM
Hi Thomas,

Two things to note here:
  • your forum thread is for RadAjax Prometheus, but you are still using the old client API of the control. All Prometheus controls are built on top of MS AJAX and you should use $find to get reference to the client object.
  • when invoking a custom ajax request on the client, the initiator is always the AjaxManager/AjaxPanel respectively. In your case it would be the AjaxManager, but in your AjaxSettings you have set initiator as some AjaxPanel? Change that to the AjaxManager and it would work.
Hope this helps.
Kind regards,
Steve
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Thomas Eberhard
Top achievements
Rank 2
answered on 14 Mar 2008, 10:49 AM
The invocation of the function in the code behind is working just fine. The output of the javascript, however, does not seem to happen. I have made the changes you suggested and the javascript alert box is still not being called.
0
Accepted
Steve
Telerik team
answered on 14 Mar 2008, 04:22 PM
Hi Thomas,

I've attached a sample project according to my description of the necessary changes and it works. Give it a spin and let us know if further help is needed.

Regards,
Steve
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Thomas Eberhard
Top achievements
Rank 2
answered on 14 Mar 2008, 06:22 PM
I couldn't get your code to work either when copied/pasted into the page I am attempting to get it to work in. But, I've discovered the problem.

It has to do with a MasterPage. In the MasterPage I have a RadWindow control that I use to popup windows. Within that page is a ScriptManager tag for the RadWindow. Except that I had the ScriptManager below the contentplaceholder but for some reason it didn't generate the error. The ScriptManager must appear before any controls that need it.

So the end result is that I moved the ScriptManager before the contentplaceholder and everything is working great. Thanks for your help.
Tags
Ajax
Asked by
Thomas Eberhard
Top achievements
Rank 2
Answers by
Steve
Telerik team
Thomas Eberhard
Top achievements
Rank 2
Share this question
or