ASP.Net ScriptControl - add Javascript get_events method: possible?

So, I ran into a problem, apparently, the get_events method is only "included" in the ExtenderControl class.

What do I need to do:

Be able to call the get_events Javascript method using a ScriptControl, as using ExtenderControl is actually not possible at the moment.

I hope there is an easy way to make the scriptControl javascript object inherit something (if possible).

+1


source to share


1 answer


It turns out the get_events method is really easy to create. You just need a field to store the dictionary, a couple of lines of code, and something to trigger an event if needed:

getEvents: function() 
{
    if (this._events == null) 
    {
        this._events = new Sys.EventHandlerList();
    }

    return this._events;
},

      

And now for access:



onItemSelected: function(args)
{
   this.raiseEvent('userItemSelected', args);
},

raiseEvent: function(eventName, eventArgs)
{
    var handler = this.getEvents().getHandler(eventName);
    if(handler)
    {
        handler(this._autoComplete, eventArgs);
    }

},

      

Basically events are just a dictionary that contains the name of the event and a reference to the method to call. When you have a method (handler), it's just a matter of calling it.

+1


source







All Articles