How to Define Default Event?

Discussion in 'ASP .Net Building Controls' started by Stephen Barrett, Feb 10, 2004.

  1. We have a couple of webcontrols that we have built for our web development.
    All these controls basically listen to a single event handler. The controls
    are currently loaded into our toolbox for drag and drop addition.

    I have noticed that on the controls from MSFT, if you double click it in
    design view, it wires up the event handler in the OnInit and takes you to
    code view.

    I would like to add this functionality to our controls to save developer
    time doing it manually by switching to "event" view on the property page of
    the control and manually typing in the EventHandler property.

    Can someone point me in the right direction or let me know how to do this?

    TIA,
    Stephen
     
    Stephen Barrett, Feb 10, 2004
    #1
    1. Advertising

  2. hi Steven,
    You must expose this event to the client from within your control. In the
    public event handler, your custom control exposes, mark it as you would with
    any property you want exposed in the propertygrid. The events go in the
    action category like :

    [
    Category("Action"),
    Description("Raised when MySomeButton click occurs.")
    ]
    public event SomebuttoEventHandler MyButtonCommand {
    add {
    Events.AddHandler(EventMyButtonCommand, value);
    }
    remove {
    Events.RemoveHandler(EventMyButtonCommand, value);
    }
    }

    "Stephen Barrett" <stephen_barrett@aoncons_nospam.com> wrote in message
    news:%...
    > We have a couple of webcontrols that we have built for our web

    development.
    > All these controls basically listen to a single event handler. The

    controls
    > are currently loaded into our toolbox for drag and drop addition.
    >
    > I have noticed that on the controls from MSFT, if you double click it in
    > design view, it wires up the event handler in the OnInit and takes you to
    > code view.
    >
    > I would like to add this functionality to our controls to save developer
    > time doing it manually by switching to "event" view on the property page

    of
    > the control and manually typing in the EventHandler property.
    >
    > Can someone point me in the right direction or let me know how to do this?
    >
    > TIA,
    > Stephen
    >
    >
     
    Alessandro Zifiglio, Feb 11, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. micky

    default.mspx or default.do

    micky, Dec 16, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    513
    Andrew Robinson
    Dec 17, 2005
  2. Gaetan
    Replies:
    3
    Views:
    1,475
    Juan T. Llibre
    Feb 14, 2006
  3. theotyflos
    Replies:
    3
    Views:
    496
    Thomas Matthews
    Feb 19, 2004
  4. robin liu
    Replies:
    3
    Views:
    847
    Robin Liu
    Apr 21, 2006
  5. Brian Takita

    #define _ and #define __

    Brian Takita, Jan 23, 2006, in forum: Ruby
    Replies:
    0
    Views:
    499
    Brian Takita
    Jan 23, 2006
Loading...

Share This Page