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

how to call ajax control method on response of another ajax control event

1 Answer 53 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
tomas
Top achievements
Rank 1
tomas asked on 11 Feb 2009, 05:33 PM
Hi.

I have calendar control.

I have this C# code:


this.dateTimePicker.ClientEvents.OnPopupOpening
 = 
                "$find('" + anotherControl.ClientID + "').SetDate";

This code is wrong. Method is run, but "this" keyword is not the reference to that anohter control but something else. (I dont know).  Running SetDate throws JavaScript error (this.get_element() does not exist).

Client side object of that another control is looking like that:

Type.registerNamespace('FluTel');  
 
FluTel.DateTimePicker = function(element)  
{  
    this._innerControl = null;  
    this.first_name = "adam";  
    this.last_name = "drda";  
      
    FluTel.DateTimePicker.initializeBase(this, [element]);  
}  
 
FluTel.DateTimePicker.prototype = {  
    initialize : function()  
    {  
        FluTel.DateTimePicker.callBaseMethod(this,'initialize');  
        // var element = this.get_element();  
        // Sys.Debug.fail("");  
      
    },  
 
  dispose : function() {  
      $clearHandlers(this.get_element());  
 
      FluTel.DateTimePicker.callBaseMethod(this, 'dispose');  
  },  
      
    SetDate : function()  
    {  
        this._innerControl = $find(this.get_element().innerControlId);  
        alert("I am here " + this._innerControl);  
    }  
}  
 
FluTel.DateTimePicker.registerClass('FluTel.DateTimePicker', Sys.UI.Control);  
 
if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded(); 


Yes, I can call special in page function and this throws no error and everything is ok. (Called by 

this.dateTimePicker.ClientEvents.OnPopupOpening
 = "runSetDate"; 




<
script> 
function runSetDate()  
{  
$find('thatObjectId').SetDate();  
}  
</script> 


So It seems to me that I must create these in page functions for every method calling when one Ajax control calls the other.

:-(

Thank you for any help.

Tom


1 Answer, 1 is accepted

Sort by
0
Accepted
Sebastian
Telerik team
answered on 16 Feb 2009, 12:25 PM
Hi Tom,

Indeed your assumption is correct - you can assign merely the name of the javascript handling through the OnPopupOpening client handler of RadDatePicker. Calling directly javascript methods or passing arguments to the relevant handler is not supported.

Note that you can specify common client event handlers for several date pickers on the page and determine for which control this event has been raised checking the id of the sender argument (first argument passed in the handler):

<script>    
function runSetDate(sender, eventArgs)     
{     
  alert(sender.get_id());  
}     
</script>    
 

Thus you can execute your custom method dependant on the respective date picker instance.

Kind regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Calendar
Asked by
tomas
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Share this question
or