howto: bubble-up events

Discussion in 'ASP .Net Web Controls' started by Support, May 26, 2005.

  1. Support

    Support Guest

    Hello:
    using Vb.net ..
    I have an asp.net web page: home.aspx, with a placeholder that loads
    Inspections.ascx
    UserCategories.aspx has a button MySubmit that submits information:
    what I want is some code that I would place in home.aspx that would detect
    that MySubmit was clicked and get the name of the button (in this case,
    MySubmit)

    Is there a way to do this ?
    Thanks
    Terry
     
    Support, May 26, 2005
    #1
    1. Advertising

  2. Support

    Brock Allen Guest

    Yep. Add an event to your usercontrol and then in the UC's click event handler
    for the button, raise the event:

    class MyUC
    {
    public event EventHandler MySubmit;

    private void Button1_Click()
    {
    if (MySubmit != null) MySubmit(this, EventArgs.Empty);
    }
    }

    The in the page, just handle the OnMySubmit like you'd handle any event from
    any other control.

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > Hello:
    > using Vb.net ..
    > I have an asp.net web page: home.aspx, with a placeholder that loads
    > Inspections.ascx
    > UserCategories.aspx has a button MySubmit that submits information:
    > what I want is some code that I would place in home.aspx that would
    > detect
    > that MySubmit was clicked and get the name of the button (in this
    > case,
    > MySubmit)
    > Is there a way to do this ?
    > Thanks
    > Terry
     
    Brock Allen, May 26, 2005
    #2
    1. Advertising

  3. Support

    Support Guest

    thanks - i have to understand the c syntax ...
    Terry
    "Brock Allen" <> wrote in message
    news:...
    > Yep. Add an event to your usercontrol and then in the UC's click event
    > handler for the button, raise the event:
    >
    > class MyUC
    > {
    > public event EventHandler MySubmit;
    >
    > private void Button1_Click()
    > {
    > if (MySubmit != null) MySubmit(this, EventArgs.Empty);
    > }
    > }
    >
    > The in the page, just handle the OnMySubmit like you'd handle any event
    > from any other control.
    >
    > -Brock
    > DevelopMentor
    > http://staff.develop.com/ballen
    >
    >
    >
    >> Hello:
    >> using Vb.net ..
    >> I have an asp.net web page: home.aspx, with a placeholder that loads
    >> Inspections.ascx
    >> UserCategories.aspx has a button MySubmit that submits information:
    >> what I want is some code that I would place in home.aspx that would
    >> detect
    >> that MySubmit was clicked and get the name of the button (in this
    >> case,
    >> MySubmit)
    >> Is there a way to do this ?
    >> Thanks
    >> Terry

    >
    >
    >
     
    Support, May 26, 2005
    #3
    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. Ingmar Seifert

    tool to draw FSM bubble diagram

    Ingmar Seifert, Jul 31, 2003, in forum: VHDL
    Replies:
    5
    Views:
    23,191
    Pedro Claro
    Aug 1, 2003
  2. mlimber
    Replies:
    0
    Views:
    818
    mlimber
    Aug 5, 2008
  3. Marc Castrechini

    Composite Control with Templates - DropDownList bubble events

    Marc Castrechini, Sep 22, 2006, in forum: ASP .Net Building Controls
    Replies:
    4
    Views:
    314
    Walter Wang [MSFT]
    Sep 29, 2006
  4. Chris

    Events Events Events Please Help

    Chris, Aug 30, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    388
    Chris
    Aug 30, 2005
  5. Iain

    Control in template does not bubble events

    Iain, Jun 11, 2006, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    202
    Alessandro Zifiglio
    Jun 13, 2006
Loading...

Share This Page