Events in user control

Discussion in 'ASP .Net' started by =?Utf-8?B?QXJuZSBHYXJ2YW5kZXI=?=, Jul 13, 2007.

  1. How do I fire on an event in a user control that gets posted back to the web
    form that is hosting the usercontrol?
    What is the best way to communicate from a usercontrol to a a webform
    hosting the usercontrol?
    --
    Arne Garvander
    (I program VB.Net for fun and C# to get paid.)
     
    =?Utf-8?B?QXJuZSBHYXJ2YW5kZXI=?=, Jul 13, 2007
    #1
    1. Advertising

  2. =?Utf-8?B?QXJuZSBHYXJ2YW5kZXI=?=

    Alex Meleta Guest

    Alex Meleta, Jul 13, 2007
    #2
    1. Advertising

  3. =?Utf-8?B?QXJuZSBHYXJ2YW5kZXI=?=

    Masudur Guest

    Hi...

    its pretty simple declare a public event with appropriate delegate....
    public event EventHandler MyButtonClicked;

    do fire it like this

    protected void GridViewTasks_RowDataBound(object sender,
    GridViewRowEventArgs e)
    {
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
    //e.Row.Attributes.Add("myCustomAttribute", true);
    if (MyButtonClicked!=null)
    {
    MyButtonClicked(sender, e);
    }
    }
    }

    and in page do subscript the event...

    myusercontrol.MyButtonClicked+=
     
    Masudur, Jul 14, 2007
    #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. Sunkam Santhoshi

    Events for menu user control using ie web control

    Sunkam Santhoshi, Dec 16, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    410
    Sunkam Santhoshi
    Dec 16, 2003
  2. Mad Scientist Jr
    Replies:
    0
    Views:
    644
    Mad Scientist Jr
    Mar 22, 2006
  3. Jonathan Wood

    User Control to Control Other User Control

    Jonathan Wood, Jan 24, 2010, in forum: ASP .Net
    Replies:
    4
    Views:
    557
    Jonathan Wood
    Feb 2, 2010
  4. Chris

    Events Events Events Please Help

    Chris, Aug 30, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    374
    Chris
    Aug 30, 2005
  5. Replies:
    1
    Views:
    159
    Peter Michaux
    Apr 27, 2007
Loading...

Share This Page