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. Advertisements

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

    Alex Meleta Guest

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

  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. Advertisements

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. Tom Rowton
    Replies:
    2
    Views:
    924
    Tom Rowton
    Aug 1, 2003
  2. Sunkam Santhoshi

    Events for menu user control using ie web control

    Sunkam Santhoshi, Dec 16, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    522
    Sunkam Santhoshi
    Dec 16, 2003
  3. vatech1993
    Replies:
    4
    Views:
    5,904
    =?Utf-8?B?U8Opcmdpbw==?=
    Dec 11, 2004
  4. Replies:
    0
    Views:
    594
  5. Mad Scientist Jr
    Replies:
    0
    Views:
    892
    Mad Scientist Jr
    Mar 22, 2006
  6. Jonathan Wood

    User Control to Control Other User Control

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

    Events Events Events Please Help

    Chris, Aug 30, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    663
    Chris
    Aug 30, 2005
  8. Replies:
    1
    Views:
    260
    Peter Michaux
    Apr 27, 2007
Loading...