Using a custom event.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tshad

    Using a custom event.

    I was looking at a page that showed how to set up a custom event and it
    seems to work ok. But I am not sure how I would use it. How would I
    subscribe to it. There is actual action (such as pressing a button or
    changing text in a textbox).

    It gets set up and on the user control on my web page I can see the event
    from intellisense. So it seems to be set up, but I am trying to get an easy
    example of how I would now use this event.

    The conrol is just an SqlDataSource that will look up persons from the
    Persons table based on State.

    But how do I get the event to work?

    I have 3 files: the control, the default page that uses the control and an
    "EventArgs" class to handle the parameters - in this case just State.

    WebUserControl1 .ascx
    *************** *************** *****
    <%@ Control Language="C#" AutoEventWireup ="true"
    CodeBehind="Web UserControl1.as cx.cs"
    Inherits="UserC ontrolSQL.WebUs erControl1" %>
    <asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server"
    ConnectionStrin g="Data Source=PTERADON \AW3000_INSTANC E;Initial
    Catalog=CSpearA ndAssociates;In tegrated Security=True"
    OnSelecting="Sq lDataSource1_Se lecting"
    SelectCommand=" SELECT FirstName,Lastn ame FROM Persons Join Address on
    (Persons.Addres sID = Addresses.Addre ssID) WHERE State = @State" "
    SelectCommandTy pe="Text">
    <SelectParamete rs>
    <asp:Paramete r Name="State" Size="2" Type="String" />
    </SelectParameter s>
    </asp:SqlDataSour ce>
    *************** *************** *****

    WebUserControl1 .ascx.cs
    *************** *************** *********
    using System;
    using System.Collecti ons.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.W ebControls;

    namespace UserControlSQL
    {
    public partial class WebUserControl1 : System.Web.UI.U serControl
    {
    public event SelectingEventH andler Selecting;
    protected void Page_Load(objec t sender, EventArgs e)
    {

    }

    protected void SqlDataSource1_ Selecting(objec t sender,
    SqlDataSourceSe lectingEventArg s e)
    {
    SelectingEventA rgs args = new SelectingEventA rgs();

    // Retrieve the parameter values from the consumer
    if (Selecting != null)
    {
    Selecting(this, args);
    }

    // Use the values set by the consumer to set the values of the
    parameters
    e.Command.Param eters["@State"].Value = args.State;
    }
    }
    }
    *************** *************** *********

    Default.aspx
    *************** *************** *************** *
    <%@ Page Language="C#" AutoEventWireup ="true" CodeBehind="Def ault.aspx.cs"
    Inherits="UserC ontrolSQL._Defa ult" %>
    <%@ Register Src="WebUserCon trol1.ascx" TagName="UserCo ntrol" TagPrefix="uc"
    %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title></title>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>
    <uc:UserContr ol ID="UserControl 1" runat="server"
    OnSelecting="Us erControl1_Sele cting" />
    </div>
    </form>
    </body>
    </html>
    *************** *************** *************** *

    Default.aspx.cs
    *************** *************** *************** ***
    using System;
    using System.Collecti ons.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.W ebControls;

    namespace UserControlSQL
    {
    public partial class _Default : System.Web.UI.P age
    {
    protected void Page_Load(objec t sender, EventArgs e)
    {
    if (!IsPostBack)
    {
    }
    else
    {
    }
    }
    protected void Page_Init(objec t sender, EventArgs e)
    {
    UserControl1.Se lecting += new
    SelectingEventH andler(UserCont rol1_Selecting) ;
    if (!IsPostBack)
    {
    }
    else
    {
    }
    }
    protected void UserControl1_Se lecting(object sender,
    SelectingEventA rgs e)
    {

    // Do something here to determine what state to specify.

    }
    }
    }
    *************** *************** *************** ****

    SelectingEventA rgs.cs
    *************** *************** ****
    using System;
    using System.Collecti ons.Generic;
    using System.Linq;
    using System.Web;

    namespace UserControlSQL
    {
    public delegate void SelectingEventH andler(object sender,
    SelectingEventA rgs e);

    public class SelectingEventA rgs : EventArgs
    {
    string _State;

    public string State
    {
    get { return _State; }
    set { _State = value; }
    }
    }

    }
    *************** *************** ****

    In my example, I am subscribing to the event in 2 ways:

    UserControl1.Se lecting += new
    SelectingEventH andler(UserCont rol1_Selecting) ;
    and
    <uc:UserContr ol ID="UserControl 1" runat="server"
    OnSelecting="Us erControl1_Sele cting" />

    And as I mentioned, in the UserControl, I am using OnSelecting which shows
    in intellisense.

    But what would I do to actually use the event in my default page?

    Thanks,

    Tom




  • Gregory A. Beamer \(Cowboy\) - MVP

    #2
    Re: Using a custom event.

    Wire the custom event to a routine that handles it. The signature will look
    like this:

    control.Event += new EventHandler(me thodName);

    Try this:
    Now, next, and beyond: Tracking need-to-know trends at the intersection of business and technology


    --
    Gregory A. Beamer
    MVP, MCP: +I, SE, SD, DBA

    Subscribe to my blog


    or just read it:


    *************** *************** **************
    | Think outside the box! |
    *************** *************** **************
    "tshad" <tfs@dslextreme .comwrote in message
    news:%233x2r5uM JHA.276@TK2MSFT NGP02.phx.gbl.. .
    >I was looking at a page that showed how to set up a custom event and it
    >seems to work ok. But I am not sure how I would use it. How would I
    >subscribe to it. There is actual action (such as pressing a button or
    >changing text in a textbox).
    >
    It gets set up and on the user control on my web page I can see the event
    from intellisense. So it seems to be set up, but I am trying to get an
    easy example of how I would now use this event.
    >
    The conrol is just an SqlDataSource that will look up persons from the
    Persons table based on State.
    >
    But how do I get the event to work?
    >
    I have 3 files: the control, the default page that uses the control and an
    "EventArgs" class to handle the parameters - in this case just State.
    >
    WebUserControl1 .ascx
    *************** *************** *****
    <%@ Control Language="C#" AutoEventWireup ="true"
    CodeBehind="Web UserControl1.as cx.cs"
    Inherits="UserC ontrolSQL.WebUs erControl1" %>
    <asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server"
    ConnectionStrin g="Data Source=PTERADON \AW3000_INSTANC E;Initial
    Catalog=CSpearA ndAssociates;In tegrated Security=True"
    OnSelecting="Sq lDataSource1_Se lecting"
    SelectCommand=" SELECT FirstName,Lastn ame FROM Persons Join Address on
    (Persons.Addres sID = Addresses.Addre ssID) WHERE State = @State" "
    SelectCommandTy pe="Text">
    <SelectParamete rs>
    <asp:Paramete r Name="State" Size="2" Type="String" />
    </SelectParameter s>
    </asp:SqlDataSour ce>
    *************** *************** *****
    >
    WebUserControl1 .ascx.cs
    *************** *************** *********
    using System;
    using System.Collecti ons.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.W ebControls;
    >
    namespace UserControlSQL
    {
    public partial class WebUserControl1 : System.Web.UI.U serControl
    {
    public event SelectingEventH andler Selecting;
    protected void Page_Load(objec t sender, EventArgs e)
    {
    >
    }
    >
    protected void SqlDataSource1_ Selecting(objec t sender,
    SqlDataSourceSe lectingEventArg s e)
    {
    SelectingEventA rgs args = new SelectingEventA rgs();
    >
    // Retrieve the parameter values from the consumer
    if (Selecting != null)
    {
    Selecting(this, args);
    }
    >
    // Use the values set by the consumer to set the values of the
    parameters
    e.Command.Param eters["@State"].Value = args.State;
    }
    }
    }
    *************** *************** *********
    >
    Default.aspx
    *************** *************** *************** *
    <%@ Page Language="C#" AutoEventWireup ="true" CodeBehind="Def ault.aspx.cs"
    Inherits="UserC ontrolSQL._Defa ult" %>
    <%@ Register Src="WebUserCon trol1.ascx" TagName="UserCo ntrol"
    TagPrefix="uc" %>
    >
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
    >
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title></title>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>
    <uc:UserContr ol ID="UserControl 1" runat="server"
    OnSelecting="Us erControl1_Sele cting" />
    </div>
    </form>
    </body>
    </html>
    *************** *************** *************** *
    >
    Default.aspx.cs
    *************** *************** *************** ***
    using System;
    using System.Collecti ons.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.W ebControls;
    >
    namespace UserControlSQL
    {
    public partial class _Default : System.Web.UI.P age
    {
    protected void Page_Load(objec t sender, EventArgs e)
    {
    if (!IsPostBack)
    {
    }
    else
    {
    }
    }
    protected void Page_Init(objec t sender, EventArgs e)
    {
    UserControl1.Se lecting += new
    SelectingEventH andler(UserCont rol1_Selecting) ;
    if (!IsPostBack)
    {
    }
    else
    {
    }
    }
    protected void UserControl1_Se lecting(object sender,
    SelectingEventA rgs e)
    {
    >
    // Do something here to determine what state to specify.
    >
    }
    }
    }
    *************** *************** *************** ****
    >
    SelectingEventA rgs.cs
    *************** *************** ****
    using System;
    using System.Collecti ons.Generic;
    using System.Linq;
    using System.Web;
    >
    namespace UserControlSQL
    {
    public delegate void SelectingEventH andler(object sender,
    SelectingEventA rgs e);
    >
    public class SelectingEventA rgs : EventArgs
    {
    string _State;
    >
    public string State
    {
    get { return _State; }
    set { _State = value; }
    }
    }
    >
    }
    *************** *************** ****
    >
    In my example, I am subscribing to the event in 2 ways:
    >
    UserControl1.Se lecting += new
    SelectingEventH andler(UserCont rol1_Selecting) ;
    and
    <uc:UserContr ol ID="UserControl 1" runat="server"
    OnSelecting="Us erControl1_Sele cting" />
    >
    And as I mentioned, in the UserControl, I am using OnSelecting which shows
    in intellisense.
    >
    But what would I do to actually use the event in my default page?
    >
    Thanks,
    >
    Tom
    >
    >
    >
    >

    Comment

    • bruce barker

      #3
      Re: Using a custom event.

      i not sure what your issue is.

      you created a user control that defines an event. that control hosts a
      control (SqlDataSource) that raises an event. in the subscribed event
      handler, the control raises the Selecting event.

      default.aspx subscribed twice to the event, once in the aspx via the
      OnSelecting property and one in the code behind adding a delegate to the
      actual event property. the OnSelecting is how events are exposed in aspx
      syntax. when compiled they generate the similar code as your codebehind
      version.

      as you have no code to actually fire the SqlDataSource's event, not much
      happens. if you call the Select method of the SqlDataSource the event
      should fire.

      -- bruce (sqlwork.com)

      tshad wrote:
      I was looking at a page that showed how to set up a custom event and it
      seems to work ok. But I am not sure how I would use it. How would I
      subscribe to it. There is actual action (such as pressing a button or
      changing text in a textbox).
      >
      It gets set up and on the user control on my web page I can see the event
      from intellisense. So it seems to be set up, but I am trying to get an easy
      example of how I would now use this event.
      >
      The conrol is just an SqlDataSource that will look up persons from the
      Persons table based on State.
      >
      But how do I get the event to work?
      >
      I have 3 files: the control, the default page that uses the control and an
      "EventArgs" class to handle the parameters - in this case just State.
      >
      WebUserControl1 .ascx
      *************** *************** *****
      <%@ Control Language="C#" AutoEventWireup ="true"
      CodeBehind="Web UserControl1.as cx.cs"
      Inherits="UserC ontrolSQL.WebUs erControl1" %>
      <asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server"
      ConnectionStrin g="Data Source=PTERADON \AW3000_INSTANC E;Initial
      Catalog=CSpearA ndAssociates;In tegrated Security=True"
      OnSelecting="Sq lDataSource1_Se lecting"
      SelectCommand=" SELECT FirstName,Lastn ame FROM Persons Join Address on
      (Persons.Addres sID = Addresses.Addre ssID) WHERE State = @State" "
      SelectCommandTy pe="Text">
      <SelectParamete rs>
      <asp:Paramete r Name="State" Size="2" Type="String" />
      </SelectParameter s>
      </asp:SqlDataSour ce>
      *************** *************** *****
      >
      WebUserControl1 .ascx.cs
      *************** *************** *********
      using System;
      using System.Collecti ons.Generic;
      using System.Linq;
      using System.Web;
      using System.Web.UI;
      using System.Web.UI.W ebControls;
      >
      namespace UserControlSQL
      {
      public partial class WebUserControl1 : System.Web.UI.U serControl
      {
      public event SelectingEventH andler Selecting;
      protected void Page_Load(objec t sender, EventArgs e)
      {
      >
      }
      >
      protected void SqlDataSource1_ Selecting(objec t sender,
      SqlDataSourceSe lectingEventArg s e)
      {
      SelectingEventA rgs args = new SelectingEventA rgs();
      >
      // Retrieve the parameter values from the consumer
      if (Selecting != null)
      {
      Selecting(this, args);
      }
      >
      // Use the values set by the consumer to set the values of the
      parameters
      e.Command.Param eters["@State"].Value = args.State;
      }
      }
      }
      *************** *************** *********
      >
      Default.aspx
      *************** *************** *************** *
      <%@ Page Language="C#" AutoEventWireup ="true" CodeBehind="Def ault.aspx.cs"
      Inherits="UserC ontrolSQL._Defa ult" %>
      <%@ Register Src="WebUserCon trol1.ascx" TagName="UserCo ntrol" TagPrefix="uc"
      %>
      >
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
      >
      <html xmlns="http://www.w3.org/1999/xhtml" >
      <head runat="server">
      <title></title>
      </head>
      <body>
      <form id="form1" runat="server">
      <div>
      <uc:UserContr ol ID="UserControl 1" runat="server"
      OnSelecting="Us erControl1_Sele cting" />
      </div>
      </form>
      </body>
      </html>
      *************** *************** *************** *
      >
      Default.aspx.cs
      *************** *************** *************** ***
      using System;
      using System.Collecti ons.Generic;
      using System.Linq;
      using System.Web;
      using System.Web.UI;
      using System.Web.UI.W ebControls;
      >
      namespace UserControlSQL
      {
      public partial class _Default : System.Web.UI.P age
      {
      protected void Page_Load(objec t sender, EventArgs e)
      {
      if (!IsPostBack)
      {
      }
      else
      {
      }
      }
      protected void Page_Init(objec t sender, EventArgs e)
      {
      UserControl1.Se lecting += new
      SelectingEventH andler(UserCont rol1_Selecting) ;
      if (!IsPostBack)
      {
      }
      else
      {
      }
      }
      protected void UserControl1_Se lecting(object sender,
      SelectingEventA rgs e)
      {
      >
      // Do something here to determine what state to specify.
      >
      }
      }
      }
      *************** *************** *************** ****
      >
      SelectingEventA rgs.cs
      *************** *************** ****
      using System;
      using System.Collecti ons.Generic;
      using System.Linq;
      using System.Web;
      >
      namespace UserControlSQL
      {
      public delegate void SelectingEventH andler(object sender,
      SelectingEventA rgs e);
      >
      public class SelectingEventA rgs : EventArgs
      {
      string _State;
      >
      public string State
      {
      get { return _State; }
      set { _State = value; }
      }
      }
      >
      }
      *************** *************** ****
      >
      In my example, I am subscribing to the event in 2 ways:
      >
      UserControl1.Se lecting += new
      SelectingEventH andler(UserCont rol1_Selecting) ;
      and
      <uc:UserContr ol ID="UserControl 1" runat="server"
      OnSelecting="Us erControl1_Sele cting" />
      >
      And as I mentioned, in the UserControl, I am using OnSelecting which shows
      in intellisense.
      >
      But what would I do to actually use the event in my default page?
      >
      Thanks,
      >
      Tom
      >
      >
      >
      >

      Comment

      • tshad

        #4
        Re: Using a custom event.


        "bruce barker" <nospam@nospam. comwrote in message
        news:OpKf87zMJH A.2324@TK2MSFTN GP06.phx.gbl...
        >i not sure what your issue is.
        >
        you created a user control that defines an event. that control hosts a
        control (SqlDataSource) that raises an event. in the subscribed event
        handler, the control raises the Selecting event.
        >
        default.aspx subscribed twice to the event, once in the aspx via the
        OnSelecting property and one in the code behind adding a delegate to the
        actual event property. the OnSelecting is how events are exposed in aspx
        syntax. when compiled they generate the similar code as your codebehind
        version.
        >
        Would that mean that I would get my same function called twice?
        as you have no code to actually fire the SqlDataSource's event, not much
        happens. if you call the Select method of the SqlDataSource the event
        should fire.
        >
        So in my control I would call the SqlDataSource1_ Selecting function
        somewhere?

        I am a little confused as to how this would work.

        Apparently, the Web page is supposed to pass the parameter (State) to the
        web control before it does the actual Select statement.

        This is a little confusing.

        I assume that the SqlDataSource1_ Selecting would get called from the web
        control and that would raise the Selecting event.

        Then the control would run the method specified by the web page
        (UserControl1_S electing) which would then set the SelectingEventA rgs to a
        selected State (e.State = "CA").

        Then back at the control, it would get the State from the SelectingEventA rgs
        that was passed from the Web Page (e.Command.Para meters["@State"].Value =
        args.State;).

        Then the SqlDataSource1_ Selecting method would execute the Select statement.

        But what would start this running?

        I assume that nothing can happen until the Web Page has the State to give
        the control. So what would tell the control to Raise the event?

        Thanks,

        Tom
        -- bruce (sqlwork.com)
        >
        tshad wrote:
        >I was looking at a page that showed how to set up a custom event and it
        >seems to work ok. But I am not sure how I would use it. How would I
        >subscribe to it. There is actual action (such as pressing a button or
        >changing text in a textbox).
        >>
        >It gets set up and on the user control on my web page I can see the event
        >from intellisense. So it seems to be set up, but I am trying to get an
        >easy example of how I would now use this event.
        >>
        >The conrol is just an SqlDataSource that will look up persons from the
        >Persons table based on State.
        >>
        >But how do I get the event to work?
        >>
        >I have 3 files: the control, the default page that uses the control and
        >an "EventArgs" class to handle the parameters - in this case just State.
        >>
        >WebUserControl 1.ascx
        >************** *************** ******
        ><%@ Control Language="C#" AutoEventWireup ="true"
        >CodeBehind="We bUserControl1.a scx.cs"
        >Inherits="User ControlSQL.WebU serControl1" %>
        ><asp:SqlDataSo urce ID="SqlDataSour ce1" runat="server"
        > ConnectionStrin g="Data Source=PTERADON \AW3000_INSTANC E;Initial
        >Catalog=CSA;In tegrated Security=True"
        > OnSelecting="Sq lDataSource1_Se lecting"
        > SelectCommand=" SELECT FirstName,Lastn ame FROM Persons Join Address on
        >(Persons.Addre ssID = Addresses.Addre ssID) WHERE State = @State" "
        > SelectCommandTy pe="Text">
        ><SelectParamet ers>
        ><asp:Paramet er Name="State" Size="2" Type="String" />
        ></SelectParameter s>
        ></asp:SqlDataSour ce>
        >************** *************** ******
        >>
        >WebUserControl 1.ascx.cs
        >************** *************** **********
        >using System;
        >using System.Collecti ons.Generic;
        >using System.Linq;
        >using System.Web;
        >using System.Web.UI;
        >using System.Web.UI.W ebControls;
        >>
        >namespace UserControlSQL
        >{
        > public partial class WebUserControl1 : System.Web.UI.U serControl
        > {
        > public event SelectingEventH andler Selecting;
        > protected void Page_Load(objec t sender, EventArgs e)
        > {
        >>
        > }
        >>
        > protected void SqlDataSource1_ Selecting(objec t sender,
        >SqlDataSourceS electingEventAr gs e)
        > {
        > SelectingEventA rgs args = new SelectingEventA rgs();
        >>
        > // Retrieve the parameter values from the consumer
        > if (Selecting != null)
        > {
        > Selecting(this, args);
        > }
        >>
        > // Use the values set by the consumer to set the values of
        >the parameters
        > e.Command.Param eters["@State"].Value = args.State;
        > }
        > }
        >}
        >************** *************** **********
        >>
        >Default.aspx
        >************** *************** *************** **
        ><%@ Page Language="C#" AutoEventWireup ="true"
        >CodeBehind="De fault.aspx.cs" Inherits="UserC ontrolSQL._Defa ult" %>
        ><%@ Register Src="WebUserCon trol1.ascx" TagName="UserCo ntrol"
        >TagPrefix="u c" %>
        >>
        ><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        >"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
        >>
        ><html xmlns="http://www.w3.org/1999/xhtml" >
        ><head runat="server">
        > <title></title>
        ></head>
        ><body>
        > <form id="form1" runat="server">
        > <div>
        > <uc:UserContr ol ID="UserControl 1" runat="server"
        >OnSelecting="U serControl1_Sel ecting" />
        > </div>
        > </form>
        ></body>
        ></html>
        >************** *************** *************** **
        >>
        >Default.aspx.c s
        >************** *************** *************** ****
        >using System;
        >using System.Collecti ons.Generic;
        >using System.Linq;
        >using System.Web;
        >using System.Web.UI;
        >using System.Web.UI.W ebControls;
        >>
        >namespace UserControlSQL
        >{
        > public partial class _Default : System.Web.UI.P age
        > {
        > protected void Page_Load(objec t sender, EventArgs e)
        > {
        > if (!IsPostBack)
        > {
        > }
        > else
        > {
        > }
        > }
        > protected void Page_Init(objec t sender, EventArgs e)
        > {
        > UserControl1.Se lecting += new
        >SelectingEvent Handler(UserCon trol1_Selecting );
        > if (!IsPostBack)
        > {
        > }
        > else
        > {
        > }
        > }
        > protected void UserControl1_Se lecting(object sender,
        >SelectingEvent Args e)
        > {
        >>
        > // Do something here to determine what state to specify.
        >>
        > }
        > }
        >}
        >************** *************** *************** *****
        >>
        >SelectingEvent Args.cs
        >************** *************** *****
        >using System;
        >using System.Collecti ons.Generic;
        >using System.Linq;
        >using System.Web;
        >>
        >namespace UserControlSQL
        >{
        > public delegate void SelectingEventH andler(object sender,
        >SelectingEvent Args e);
        >>
        > public class SelectingEventA rgs : EventArgs
        > {
        > string _State;
        >>
        > public string State
        > {
        > get { return _State; }
        > set { _State = value; }
        > }
        > }
        >>
        >}
        >************** *************** *****
        >>
        >In my example, I am subscribing to the event in 2 ways:
        >>
        > UserControl1.Se lecting += new
        >SelectingEvent Handler(UserCon trol1_Selecting );
        >and
        > <uc:UserContr ol ID="UserControl 1" runat="server"
        >OnSelecting="U serControl1_Sel ecting" />
        >>
        >And as I mentioned, in the UserControl, I am using OnSelecting which
        >shows in intellisense.
        >>
        >But what would I do to actually use the event in my default page?
        >>
        >Thanks,
        >>
        >Tom
        >>
        >>
        >>

        Comment

        • tshad

          #5
          Re: Using a custom event.


          "Gregory A. Beamer (Cowboy) - MVP" <NoSpamMgbworld @comcast.netNoS pamMwrote
          in message news:eWexV1vMJH A.5564@TK2MSFTN GP03.phx.gbl...
          Wire the custom event to a routine that handles it. The signature will
          look like this:
          >
          control.Event += new EventHandler(me thodName);
          >
          Wasn't that what I did (twice) in the Web Page (default):

          UserControl1.Se lecting += new
          SelectingEventH andler(UserCont rol1_Selecting) ;
          Good article.

          Helped a lot.

          Thanks,

          Tom
          >
          --
          Gregory A. Beamer
          MVP, MCP: +I, SE, SD, DBA
          >
          Subscribe to my blog

          >
          or just read it:

          >
          *************** *************** **************
          | Think outside the box! |
          *************** *************** **************
          "tshad" <tfs@dslextreme .comwrote in message
          news:%233x2r5uM JHA.276@TK2MSFT NGP02.phx.gbl.. .
          >>I was looking at a page that showed how to set up a custom event and it
          >>seems to work ok. But I am not sure how I would use it. How would I
          >>subscribe to it. There is actual action (such as pressing a button or
          >>changing text in a textbox).
          >>
          >It gets set up and on the user control on my web page I can see the event
          >from intellisense. So it seems to be set up, but I am trying to get an
          >easy example of how I would now use this event.
          >>
          >The conrol is just an SqlDataSource that will look up persons from the
          >Persons table based on State.
          >>
          >But how do I get the event to work?
          >>
          >I have 3 files: the control, the default page that uses the control and
          >an "EventArgs" class to handle the parameters - in this case just State.
          >>
          >WebUserControl 1.ascx
          >************** *************** ******
          ><%@ Control Language="C#" AutoEventWireup ="true"
          >CodeBehind="We bUserControl1.a scx.cs"
          >Inherits="User ControlSQL.WebU serControl1" %>
          ><asp:SqlDataSo urce ID="SqlDataSour ce1" runat="server"
          > ConnectionStrin g="Data Source=PTERADON \AW3000_INSTANC E;Initial
          >Catalog=CSA;In tegrated Security=True"
          > OnSelecting="Sq lDataSource1_Se lecting"
          > SelectCommand=" SELECT FirstName,Lastn ame FROM Persons Join Address on
          >(Persons.Addre ssID = Addresses.Addre ssID) WHERE State = @State" "
          > SelectCommandTy pe="Text">
          ><SelectParamet ers>
          ><asp:Paramet er Name="State" Size="2" Type="String" />
          ></SelectParameter s>
          ></asp:SqlDataSour ce>
          >************** *************** ******
          >>
          >WebUserControl 1.ascx.cs
          >************** *************** **********
          >using System;
          >using System.Collecti ons.Generic;
          >using System.Linq;
          >using System.Web;
          >using System.Web.UI;
          >using System.Web.UI.W ebControls;
          >>
          >namespace UserControlSQL
          >{
          > public partial class WebUserControl1 : System.Web.UI.U serControl
          > {
          > public event SelectingEventH andler Selecting;
          > protected void Page_Load(objec t sender, EventArgs e)
          > {
          >>
          > }
          >>
          > protected void SqlDataSource1_ Selecting(objec t sender,
          >SqlDataSourceS electingEventAr gs e)
          > {
          > SelectingEventA rgs args = new SelectingEventA rgs();
          >>
          > // Retrieve the parameter values from the consumer
          > if (Selecting != null)
          > {
          > Selecting(this, args);
          > }
          >>
          > // Use the values set by the consumer to set the values of the
          >parameters
          > e.Command.Param eters["@State"].Value = args.State;
          > }
          > }
          >}
          >************** *************** **********
          >>
          >Default.aspx
          >************** *************** *************** **
          ><%@ Page Language="C#" AutoEventWireup ="true"
          >CodeBehind="De fault.aspx.cs" Inherits="UserC ontrolSQL._Defa ult" %>
          ><%@ Register Src="WebUserCon trol1.ascx" TagName="UserCo ntrol"
          >TagPrefix="u c" %>
          >>
          ><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          >"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
          >>
          ><html xmlns="http://www.w3.org/1999/xhtml" >
          ><head runat="server">
          > <title></title>
          ></head>
          ><body>
          > <form id="form1" runat="server">
          > <div>
          > <uc:UserContr ol ID="UserControl 1" runat="server"
          >OnSelecting="U serControl1_Sel ecting" />
          > </div>
          > </form>
          ></body>
          ></html>
          >************** *************** *************** **
          >>
          >Default.aspx.c s
          >************** *************** *************** ****
          >using System;
          >using System.Collecti ons.Generic;
          >using System.Linq;
          >using System.Web;
          >using System.Web.UI;
          >using System.Web.UI.W ebControls;
          >>
          >namespace UserControlSQL
          >{
          > public partial class _Default : System.Web.UI.P age
          > {
          > protected void Page_Load(objec t sender, EventArgs e)
          > {
          > if (!IsPostBack)
          > {
          > }
          > else
          > {
          > }
          > }
          > protected void Page_Init(objec t sender, EventArgs e)
          > {
          > UserControl1.Se lecting += new
          >SelectingEvent Handler(UserCon trol1_Selecting );
          > if (!IsPostBack)
          > {
          > }
          > else
          > {
          > }
          > }
          > protected void UserControl1_Se lecting(object sender,
          >SelectingEvent Args e)
          > {
          >>
          > // Do something here to determine what state to specify.
          >>
          > }
          > }
          >}
          >************** *************** *************** *****
          >>
          >SelectingEvent Args.cs
          >************** *************** *****
          >using System;
          >using System.Collecti ons.Generic;
          >using System.Linq;
          >using System.Web;
          >>
          >namespace UserControlSQL
          >{
          > public delegate void SelectingEventH andler(object sender,
          >SelectingEvent Args e);
          >>
          > public class SelectingEventA rgs : EventArgs
          > {
          > string _State;
          >>
          > public string State
          > {
          > get { return _State; }
          > set { _State = value; }
          > }
          > }
          >>
          >}
          >************** *************** *****
          >>
          >In my example, I am subscribing to the event in 2 ways:
          >>
          > UserControl1.Se lecting += new
          >SelectingEvent Handler(UserCon trol1_Selecting );
          >and
          > <uc:UserContr ol ID="UserControl 1" runat="server"
          >OnSelecting="U serControl1_Sel ecting" />
          >>
          >And as I mentioned, in the UserControl, I am using OnSelecting which
          >shows in intellisense.
          >>
          >But what would I do to actually use the event in my default page?
          >>
          >Thanks,
          >>
          >Tom
          >>
          >>
          >>
          >>
          >
          >

          Comment

          • bruce barker

            #6
            Re: Using a custom event.

            you are confused.

            a sqldatasource was meant as declarative sql data access object.
            normally you'd attach to a datasource aware control that would call its
            select, insert, update or delete methods when it needed to. say a
            ListBox would call it when its DataBind method was called in the code
            behind or at PreRender by the control itself. you can directly call its
            select method, SqlDataSource1( params), but don't know why you woudl
            unless you were writing a data aware control. (of course this is all
            obsolete with linq).


            when the select method is called, before the query is passed to the
            database, the Selecting event is fired. this allows the modification of
            the parameter list.

            its still not at all clear what you are trying to do with events, or
            what you are using a SqlDataSource for.

            you should read the docs on ado.net and learn a little more about data
            access before you tackle events.

            -- bruce (sqlwork.com)


            tshad wrote:
            "bruce barker" <nospam@nospam. comwrote in message
            news:OpKf87zMJH A.2324@TK2MSFTN GP06.phx.gbl...
            >i not sure what your issue is.
            >>
            >you created a user control that defines an event. that control hosts a
            >control (SqlDataSource) that raises an event. in the subscribed event
            >handler, the control raises the Selecting event.
            >>
            >default.aspx subscribed twice to the event, once in the aspx via the
            >OnSelecting property and one in the code behind adding a delegate to the
            >actual event property. the OnSelecting is how events are exposed in aspx
            >syntax. when compiled they generate the similar code as your codebehind
            >version.
            >>
            >
            Would that mean that I would get my same function called twice?
            >
            >as you have no code to actually fire the SqlDataSource's event, not much
            >happens. if you call the Select method of the SqlDataSource the event
            >should fire.
            >>
            So in my control I would call the SqlDataSource1_ Selecting function
            somewhere?
            >
            I am a little confused as to how this would work.
            >
            Apparently, the Web page is supposed to pass the parameter (State) to the
            web control before it does the actual Select statement.
            >
            This is a little confusing.
            >
            I assume that the SqlDataSource1_ Selecting would get called from the web
            control and that would raise the Selecting event.
            >
            Then the control would run the method specified by the web page
            (UserControl1_S electing) which would then set the SelectingEventA rgs to a
            selected State (e.State = "CA").
            >
            Then back at the control, it would get the State from the SelectingEventA rgs
            that was passed from the Web Page (e.Command.Para meters["@State"].Value =
            args.State;).
            >
            Then the SqlDataSource1_ Selecting method would execute the Select statement.
            >
            But what would start this running?
            >
            I assume that nothing can happen until the Web Page has the State to give
            the control. So what would tell the control to Raise the event?
            >
            Thanks,
            >
            Tom
            >-- bruce (sqlwork.com)
            >>
            >tshad wrote:
            >>I was looking at a page that showed how to set up a custom event and it
            >>seems to work ok. But I am not sure how I would use it. How would I
            >>subscribe to it. There is actual action (such as pressing a button or
            >>changing text in a textbox).
            >>>
            >>It gets set up and on the user control on my web page I can see the event
            >>from intellisense. So it seems to be set up, but I am trying to get an
            >>easy example of how I would now use this event.
            >>>
            >>The conrol is just an SqlDataSource that will look up persons from the
            >>Persons table based on State.
            >>>
            >>But how do I get the event to work?
            >>>
            >>I have 3 files: the control, the default page that uses the control and
            >>an "EventArgs" class to handle the parameters - in this case just State.
            >>>
            >>WebUserContro l1.ascx
            >>************* *************** *******
            >><%@ Control Language="C#" AutoEventWireup ="true"
            >>CodeBehind="W ebUserControl1. ascx.cs"
            >>Inherits="Use rControlSQL.Web UserControl1" %>
            >><asp:SqlDataS ource ID="SqlDataSour ce1" runat="server"
            >> ConnectionStrin g="Data Source=PTERADON \AW3000_INSTANC E;Initial
            >>Catalog=CSA;I ntegrated Security=True"
            >> OnSelecting="Sq lDataSource1_Se lecting"
            >> SelectCommand=" SELECT FirstName,Lastn ame FROM Persons Join Address on
            >>(Persons.Addr essID = Addresses.Addre ssID) WHERE State = @State" "
            >> SelectCommandTy pe="Text">
            >><SelectParame ters>
            >><asp:Paramete r Name="State" Size="2" Type="String" />
            >></SelectParameter s>
            >></asp:SqlDataSour ce>
            >>************* *************** *******
            >>>
            >>WebUserContro l1.ascx.cs
            >>************* *************** ***********
            >>using System;
            >>using System.Collecti ons.Generic;
            >>using System.Linq;
            >>using System.Web;
            >>using System.Web.UI;
            >>using System.Web.UI.W ebControls;
            >>>
            >>namespace UserControlSQL
            >>{
            >> public partial class WebUserControl1 : System.Web.UI.U serControl
            >> {
            >> public event SelectingEventH andler Selecting;
            >> protected void Page_Load(objec t sender, EventArgs e)
            >> {
            >>>
            >> }
            >>>
            >> protected void SqlDataSource1_ Selecting(objec t sender,
            >>SqlDataSource SelectingEventA rgs e)
            >> {
            >> SelectingEventA rgs args = new SelectingEventA rgs();
            >>>
            >> // Retrieve the parameter values from the consumer
            >> if (Selecting != null)
            >> {
            >> Selecting(this, args);
            >> }
            >>>
            >> // Use the values set by the consumer to set the values of
            >>the parameters
            >> e.Command.Param eters["@State"].Value = args.State;
            >> }
            >> }
            >>}
            >>************* *************** ***********
            >>>
            >>Default.asp x
            >>************* *************** *************** ***
            >><%@ Page Language="C#" AutoEventWireup ="true"
            >>CodeBehind="D efault.aspx.cs" Inherits="UserC ontrolSQL._Defa ult" %>
            >><%@ Register Src="WebUserCon trol1.ascx" TagName="UserCo ntrol"
            >>TagPrefix="uc " %>
            >>>
            >><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
            >>"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
            >>>
            >><html xmlns="http://www.w3.org/1999/xhtml" >
            >><head runat="server">
            >> <title></title>
            >></head>
            >><body>
            >> <form id="form1" runat="server">
            >> <div>
            >> <uc:UserContr ol ID="UserControl 1" runat="server"
            >>OnSelecting=" UserControl1_Se lecting" />
            >> </div>
            >> </form>
            >></body>
            >></html>
            >>************* *************** *************** ***
            >>>
            >>Default.aspx. cs
            >>************* *************** *************** *****
            >>using System;
            >>using System.Collecti ons.Generic;
            >>using System.Linq;
            >>using System.Web;
            >>using System.Web.UI;
            >>using System.Web.UI.W ebControls;
            >>>
            >>namespace UserControlSQL
            >>{
            >> public partial class _Default : System.Web.UI.P age
            >> {
            >> protected void Page_Load(objec t sender, EventArgs e)
            >> {
            >> if (!IsPostBack)
            >> {
            >> }
            >> else
            >> {
            >> }
            >> }
            >> protected void Page_Init(objec t sender, EventArgs e)
            >> {
            >> UserControl1.Se lecting += new
            >>SelectingEven tHandler(UserCo ntrol1_Selectin g);
            >> if (!IsPostBack)
            >> {
            >> }
            >> else
            >> {
            >> }
            >> }
            >> protected void UserControl1_Se lecting(object sender,
            >>SelectingEven tArgs e)
            >> {
            >>>
            >> // Do something here to determine what state to specify.
            >>>
            >> }
            >> }
            >>}
            >>************* *************** *************** ******
            >>>
            >>SelectingEven tArgs.cs
            >>************* *************** ******
            >>using System;
            >>using System.Collecti ons.Generic;
            >>using System.Linq;
            >>using System.Web;
            >>>
            >>namespace UserControlSQL
            >>{
            >> public delegate void SelectingEventH andler(object sender,
            >>SelectingEven tArgs e);
            >>>
            >> public class SelectingEventA rgs : EventArgs
            >> {
            >> string _State;
            >>>
            >> public string State
            >> {
            >> get { return _State; }
            >> set { _State = value; }
            >> }
            >> }
            >>>
            >>}
            >>************* *************** ******
            >>>
            >>In my example, I am subscribing to the event in 2 ways:
            >>>
            >> UserControl1.Se lecting += new
            >>SelectingEven tHandler(UserCo ntrol1_Selectin g);
            >>and
            >> <uc:UserContr ol ID="UserControl 1" runat="server"
            >>OnSelecting=" UserControl1_Se lecting" />
            >>>
            >>And as I mentioned, in the UserControl, I am using OnSelecting which
            >>shows in intellisense.
            >>>
            >>But what would I do to actually use the event in my default page?
            >>>
            >>Thanks,
            >>>
            >>Tom
            >>>
            >>>
            >>>
            >

            Comment

            • tshad

              #7
              Re: Using a custom event.


              "bruce barker" <nospam@nospam. comwrote in message
              news:eK4IkS$MJH A.5696@TK2MSFTN GP03.phx.gbl...
              you are confused.
              >
              a sqldatasource was meant as declarative sql data access object. normally
              you'd attach to a datasource aware control that would call its select,
              insert, update or delete methods when it needed to. say a ListBox would
              call it when its DataBind method was called in the code behind or at
              PreRender by the control itself. you can directly call its select method,
              SqlDataSource1( params), but don't know why you woudl unless you were
              writing a data aware control. (of course this is all obsolete with linq).
              >
              >
              when the select method is called, before the query is passed to the
              database, the Selecting event is fired. this allows the modification of
              the parameter list.
              >
              its still not at all clear what you are trying to do with events, or what
              you are using a SqlDataSource for.
              >
              you should read the docs on ado.net and learn a little more about data
              access before you tackle events.
              This is just an example program (I didn't write it) on event publishing.



              I was trying to figure out how to use this as an exercise. But I am trying
              to see how I would actually use this. The article doesn't go into it. It
              doesn't show how the event would be called.

              I was using the SqlDataSource because that was what was in the article.

              Tom
              >
              -- bruce (sqlwork.com)
              >
              >
              tshad wrote:
              >"bruce barker" <nospam@nospam. comwrote in message
              >news:OpKf87zMJ HA.2324@TK2MSFT NGP06.phx.gbl.. .
              >>i not sure what your issue is.
              >>>
              >>you created a user control that defines an event. that control hosts a
              >>control (SqlDataSource) that raises an event. in the subscribed event
              >>handler, the control raises the Selecting event.
              >>>
              >>default.asp x subscribed twice to the event, once in the aspx via the
              >>OnSelecting property and one in the code behind adding a delegate to the
              >>actual event property. the OnSelecting is how events are exposed in aspx
              >>syntax. when compiled they generate the similar code as your codebehind
              >>version.
              >>>
              >>
              >Would that mean that I would get my same function called twice?
              >>
              >>as you have no code to actually fire the SqlDataSource's event, not much
              >>happens. if you call the Select method of the SqlDataSource the event
              >>should fire.
              >>>
              >So in my control I would call the SqlDataSource1_ Selecting function
              >somewhere?
              >>
              >I am a little confused as to how this would work.
              >>
              >Apparently, the Web page is supposed to pass the parameter (State) to the
              >web control before it does the actual Select statement.
              >>
              >This is a little confusing.
              >>
              >I assume that the SqlDataSource1_ Selecting would get called from the web
              >control and that would raise the Selecting event.
              >>
              >Then the control would run the method specified by the web page
              >(UserControl1_ Selecting) which would then set the SelectingEventA rgs to a
              >selected State (e.State = "CA").
              >>
              >Then back at the control, it would get the State from the
              >SelectingEvent Args that was passed from the Web Page
              >(e.Command.Par ameters["@State"].Value = args.State;).
              >>
              >Then the SqlDataSource1_ Selecting method would execute the Select
              >statement.
              >>
              >But what would start this running?
              >>
              >I assume that nothing can happen until the Web Page has the State to give
              >the control. So what would tell the control to Raise the event?
              >>
              >Thanks,
              >>
              >Tom
              >>-- bruce (sqlwork.com)
              >>>
              >>tshad wrote:
              >>>I was looking at a page that showed how to set up a custom event and it
              >>>seems to work ok. But I am not sure how I would use it. How would I
              >>>subscribe to it. There is actual action (such as pressing a button or
              >>>changing text in a textbox).
              >>>>
              >>>It gets set up and on the user control on my web page I can see the
              >>>event from intellisense. So it seems to be set up, but I am trying to
              >>>get an easy example of how I would now use this event.
              >>>>
              >>>The conrol is just an SqlDataSource that will look up persons from the
              >>>Persons table based on State.
              >>>>
              >>>But how do I get the event to work?
              >>>>
              >>>I have 3 files: the control, the default page that uses the control and
              >>>an "EventArgs" class to handle the parameters - in this case just
              >>>State.
              >>>>
              >>>WebUserContr ol1.ascx
              >>>************ *************** ********
              >>><%@ Control Language="C#" AutoEventWireup ="true"
              >>>CodeBehind=" WebUserControl1 .ascx.cs"
              >>>Inherits="Us erControlSQL.We bUserControl1" %>
              >>><asp:SqlData Source ID="SqlDataSour ce1" runat="server"
              >>> ConnectionStrin g="Data Source=PTERADON \AW3000_INSTANC E;Initial
              >>>Catalog=CSA; Integrated Security=True"
              >>> OnSelecting="Sq lDataSource1_Se lecting"
              >>> SelectCommand=" SELECT FirstName,Lastn ame FROM Persons Join Address
              >>>on (Persons.Addres sID = Addresses.Addre ssID) WHERE State = @State" "
              >>> SelectCommandTy pe="Text">
              >>><SelectParam eters>
              >>><asp:Paramet er Name="State" Size="2" Type="String" />
              >>></SelectParameter s>
              >>></asp:SqlDataSour ce>
              >>>************ *************** ********
              >>>>
              >>>WebUserContr ol1.ascx.cs
              >>>************ *************** ************
              >>>using System;
              >>>using System.Collecti ons.Generic;
              >>>using System.Linq;
              >>>using System.Web;
              >>>using System.Web.UI;
              >>>using System.Web.UI.W ebControls;
              >>>>
              >>>namespace UserControlSQL
              >>>{
              >>> public partial class WebUserControl1 : System.Web.UI.U serControl
              >>> {
              >>> public event SelectingEventH andler Selecting;
              >>> protected void Page_Load(objec t sender, EventArgs e)
              >>> {
              >>>>
              >>> }
              >>>>
              >>> protected void SqlDataSource1_ Selecting(objec t sender,
              >>>SqlDataSourc eSelectingEvent Args e)
              >>> {
              >>> SelectingEventA rgs args = new SelectingEventA rgs();
              >>>>
              >>> // Retrieve the parameter values from the consumer
              >>> if (Selecting != null)
              >>> {
              >>> Selecting(this, args);
              >>> }
              >>>>
              >>> // Use the values set by the consumer to set the values of
              >>>the parameters
              >>> e.Command.Param eters["@State"].Value = args.State;
              >>> }
              >>> }
              >>>}
              >>>************ *************** ************
              >>>>
              >>>Default.as px
              >>>************ *************** *************** ****
              >>><%@ Page Language="C#" AutoEventWireup ="true"
              >>>CodeBehind=" Default.aspx.cs " Inherits="UserC ontrolSQL._Defa ult" %>
              >>><%@ Register Src="WebUserCon trol1.ascx" TagName="UserCo ntrol"
              >>>TagPrefix="u c" %>
              >>>>
              >>><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
              >>>"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
              >>>>
              >>><html xmlns="http://www.w3.org/1999/xhtml" >
              >>><head runat="server">
              >>> <title></title>
              >>></head>
              >>><body>
              >>> <form id="form1" runat="server">
              >>> <div>
              >>> <uc:UserContr ol ID="UserControl 1" runat="server"
              >>>OnSelecting= "UserControl1_S electing" />
              >>> </div>
              >>> </form>
              >>></body>
              >>></html>
              >>>************ *************** *************** ****
              >>>>
              >>>Default.aspx .cs
              >>>************ *************** *************** ******
              >>>using System;
              >>>using System.Collecti ons.Generic;
              >>>using System.Linq;
              >>>using System.Web;
              >>>using System.Web.UI;
              >>>using System.Web.UI.W ebControls;
              >>>>
              >>>namespace UserControlSQL
              >>>{
              >>> public partial class _Default : System.Web.UI.P age
              >>> {
              >>> protected void Page_Load(objec t sender, EventArgs e)
              >>> {
              >>> if (!IsPostBack)
              >>> {
              >>> }
              >>> else
              >>> {
              >>> }
              >>> }
              >>> protected void Page_Init(objec t sender, EventArgs e)
              >>> {
              >>> UserControl1.Se lecting += new
              >>>SelectingEve ntHandler(UserC ontrol1_Selecti ng);
              >>> if (!IsPostBack)
              >>> {
              >>> }
              >>> else
              >>> {
              >>> }
              >>> }
              >>> protected void UserControl1_Se lecting(object sender,
              >>>SelectingEve ntArgs e)
              >>> {
              >>>>
              >>> // Do something here to determine what state to specify.
              >>>>
              >>> }
              >>> }
              >>>}
              >>>************ *************** *************** *******
              >>>>
              >>>SelectingEve ntArgs.cs
              >>>************ *************** *******
              >>>using System;
              >>>using System.Collecti ons.Generic;
              >>>using System.Linq;
              >>>using System.Web;
              >>>>
              >>>namespace UserControlSQL
              >>>{
              >>> public delegate void SelectingEventH andler(object sender,
              >>>SelectingEve ntArgs e);
              >>>>
              >>> public class SelectingEventA rgs : EventArgs
              >>> {
              >>> string _State;
              >>>>
              >>> public string State
              >>> {
              >>> get { return _State; }
              >>> set { _State = value; }
              >>> }
              >>> }
              >>>>
              >>>}
              >>>************ *************** *******
              >>>>
              >>>In my example, I am subscribing to the event in 2 ways:
              >>>>
              >>> UserControl1.Se lecting += new
              >>>SelectingEve ntHandler(UserC ontrol1_Selecti ng);
              >>>and
              >>> <uc:UserContr ol ID="UserControl 1" runat="server"
              >>>OnSelecting= "UserControl1_S electing" />
              >>>>
              >>>And as I mentioned, in the UserControl, I am using OnSelecting which
              >>>shows in intellisense.
              >>>>
              >>>But what would I do to actually use the event in my default page?
              >>>>
              >>>Thanks,
              >>>>
              >>>Tom
              >>>>
              >>>>
              >>>>
              >>

              Comment

              Working...