locked
RadCombo/3rd Party Control in Custom Ajax Control RRS feed

  • Question

  • User1708342303 posted

    Posted 18 hours ago (permalink)

    I am trying to create a custom Ajax control consisting of one radcombo and about 6 text box controls. I want to populate the text boxes with details of the selected item in the rad combo. I have this working with a basic html drop down, the change event on the drop down fires off which access a web service w/ json serialization and it's very simple to update the text boxes. I've declared my control like so:

    public class GlnComboPartyPicker : DataBoundControl, IPostBackDataHandler, IScriptControl, INamingContainer//, IPostBackDataHandler//, IDataSource

    I later implement the GetScriptDescriptors method:
      IEnumerable<ScriptDescriptor> IScriptControl.GetScriptDescriptors() {
          EnsureChildControls();
          ScriptControlDescriptor descriptor = new ScriptControlDescriptor("MyControlNS.MyControl", this.ClientID);

    The control renders, the radcompo is populated and scrolls nicely etc.. BUT, normally I would add a handler to a basic html dropdown in the javascript that initializes the client class:
    MyControlNS.MyControl.prototype = {
        initialize: function() {
            GLNPartyPickerControl.PartyPicker.callBaseMethod(this, 'initialize');
            $addHandlers(this._partiesDDLElement, { "change": this._selectedPartyChangedHandler }, this);

    But since the radcombo isn't a html dom object, I can't attach the event this way and every other thing I've tried has failed. How do I tell the radcombo in my custom control, on the client, what to execute when the radcombo's selected item changes? I don't seem to be able to get a reference to the client side radcombo object. Remember this is a custom control so I need to always reference a function of this, my, control.

    I've now discovered the problem is that the radCombo Telerik control dosen't exist during the client control's initilize call. So then when and where can I start interacting on the client with this 3rd party control. I need to wire up an event to call my json searilzed service and populate the rest of the control. If more info is needed please let me know and thanks for any help; i'm really stumped!

    Wednesday, March 31, 2010 1:59 PM

Answers

  • User1708342303 posted

    What I was missing was the use of the createDelegate

    Sys.Application.add_load(Function.createDelegate(this, MyControlNS.MyControl.onLoaded));


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 19, 2010 1:35 PM

All replies

  • User1708342303 posted

    Maybe a simpler way to ask this is how do I execute a control specific function after it initialized? I know the Sys.Application.add_load will add a load will add a load handler. But I have to assign this handler before the control I am looking for has been created; near the end of the initialize. I could really use some help from someone who knows Sys.Application well - please!


    Wednesday, March 31, 2010 4:36 PM
  • User1708342303 posted

    What I was missing was the use of the createDelegate

    Sys.Application.add_load(Function.createDelegate(this, MyControlNS.MyControl.onLoaded));


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 19, 2010 1:35 PM