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

RadAjaxManager1_AjaxRequest Not Firing

2 Answers 306 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Mark Galbreath
Top achievements
Rank 2
Mark Galbreath asked on 22 Dec 2009, 09:55 PM
I have RadListBox1 and RadListBox2.  They are parked in a RadPageView attached to a RadTab.  Either listbox can transfer (move) items from one to the other with the transfer button, 2x-click, or drag-n-drop.  Everything is cool.  I have a "Save" button, the purpose of which is to update RadListBox2's database table.  On button_click I am grabbing the items in RadListBox2 as a collection, parsing the collection, and transforming into a comma-delimited string all on the client in order to pass through RadAjaxManager1_AjaxRequest:

function btnClick() {  
    var list = $find("<%= radListBox2.ClientID %>");  
    var lstNames = list.get_items();  
    var arg;  
 
    if( lstNames.get_count() == 0 ) {  
 
        if (confirm("blah, blah, blah.\n\nProceed?")) {  
            arg = 0;  
        } else { return 0; }  
 
    } else {  
        arg = lstNames.get_count() + ",";  
        lstNames.forEach( function( item ) { arg = arg + item.get_text() + ","; });  
        arg = arg.substr( 0, arg.length - 1 );  
    }  
 
    var ajaxMgr = $find("<%= RadAjaxManager1.ClientID %>");  
    ajaxMgr.ajaxRequest( arg );  

I have confirmed through JavaScript alerts that all is well here.  BUT - ajaxMgr.ajaxRequest( arg ) doesn't fire its associated method in the code-behind.  RadScriptManager is set:

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest"

I have Ajax turned on in Page_Load:

RadAjaxManager.GetCurrent( Me ).EnableAJAX = True 

I have AutoPostBackOnTransfer turned off on both listboxes because nothing works when switched on:

radListBox1.AutoPostBackOnTransfer = False 
radListBox2.AutoPostBackOnTransfer = False 

And the code-behind method looks fine to me:

Protected Sub RadAjaxManager1_AjaxRequest( sender As Object, e As AjaxRequestEventArgs ) Handles RadAjaxManager1.AjaxRequest  
    Dim str_Array As String() = Split( e.Argument, "," )  
    Dim numRecords = Integer.Parse( str_Array( 0 ))  
    Dim lst_Tables As IList( Of String ) = New List( Of String )  
    Dim p_data As String = String.Empty   
 
    If numRecords > 0 And numRecords < 10 Then  
        p_data = e.Argument.Substring( 2 )  
    ElseIf numRecords > 9 And numRecords < 100 Then  
        p_data = e.Argument.Substring( 3 )  
    Else  
        p_data = e.Argument.Substring( 4 )  
    End If  
 
    ' sanity check  
    RadAjaxManager1.Alert( "numRecords = " & numRecords )  
    RadAjaxManager1.Alert( "p_data = " & p_data)  
 
    * * *  
End Sub 

But my sanity checks are never invoked.

Got any clues, guys?

Cheers!
Mark

2 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 28 Dec 2009, 03:19 PM
Hello Mark,

I guess you are not handling client click event of Save button correctly.
For your convenience I am sending sample page demonstrating that server AjaxRequest event is fired.
Please find the attachment.

All the best,
Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Mark Galbreath
Top achievements
Rank 2
answered on 28 Dec 2009, 04:49 PM
Thanks for replying, Nikolay!

The problem is this:

<AjaxSettings> 
    <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"></telerik:AjaxSetting> 
    <telerik:AjaxSetting AjaxControlID="btn_Save">  
        <UpdatedControls> 
            <telerik:AjaxUpdatedControl ControlID="radListBox1" LoadingPanelID="RadLoadingPanel1" />\  
            <telerik:AjaxUpdatedControl ControlID="radListBox2" LoadingPanelID="RadLoadingPanel1" /> 
        </UpdatedControls> 
    </telerik:AjaxSetting> 
</AjaxSettings> 

Whenever I add the AjaxSettings, the listboxes stop calling AjaxRequest from the client.  When I remove AjaxSettings, AjaxRequest is called and the database is updated, though the browser must be manually refreshed to see the changes.  This has been a PITA for over a week now.

Cheers!
Mark
Tags
ListBox
Asked by
Mark Galbreath
Top achievements
Rank 2
Answers by
Nikolay Rusev
Telerik team
Mark Galbreath
Top achievements
Rank 2
Share this question
or