Composite Custom Controls - The Event Horizon

Discussion in 'ASP .Net' started by Mr Newbie, Nov 6, 2005.

  1. Mr Newbie

    Mr Newbie Guest

    Hi,

    Im doing something really stupid here, But I cant see the wood for the
    trees. This is some of the code for my custom composite control. It renders
    fine and the buttons do cause a Post to occur. But the Click Handlers are
    not are never receiving a click event. I note that the name of the control
    is _ctl0 or 1 etc.

    <span id="MyDamnButton1" style="width:192px;Z-INDEX: 101; LEFT: 16px;
    POSITION: absolute; TOP: 24px"><input type="submit" name="_ctl0"
    value="Submit Me" /><input type="submit" name="_ctl1" value="Submit Me 2"
    /></span>

    What could I have done wrong ?

    ------------------------

    Protected btnSubmit As New System.Web.UI.WebControls.Button
    Protected btnSubmit2 As New System.Web.UI.WebControls.Button

    Protected Overrides Sub CreateChildControls()
    btnSubmit.Text = "Submit Me"
    btnSubmit2.Text = "Submit Me 2"
    Controls.Add(btnSubmit)
    Controls.Add(btnSubmit2)

    AddHandler btnSubmit.Click, AddressOf Me.Click1Handler
    AddHandler btnSubmit2.Click, AddressOf Me.Click1Handler2
    End Sub


    Private Sub Click1Handler(ByVal sender As System.Object, ByVal e As
    System.EventArgs)
    Dim a As Int16 = 0

    End Sub

    Private Sub Click1Handler2(ByVal sender As System.Object, ByVal e As
    System.EventArgs)
    Dim a As Int16 = 0
    End Sub

    --
    Best Regards

    The Inimitable Mr Newbie º¿º
     
    Mr Newbie, Nov 6, 2005
    #1
    1. Advertising

  2. Hi Mr. N,

    As I answered this in either the Framework newsgroup, or the Visual
    Studio.Net newsgroup (can't remember which at the moment) fully, I'll trust
    you to look there for the details. But because I'm a good sport, I'll give
    you the Reader's Digest Condensed version here (again, and shame on you!):

    Add an OnLoad override to the Control, and call EnsureChildControls() in
    that.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    A watched clock never boils.

    "Mr Newbie" <> wrote in message
    news:u$...
    > Hi,
    >
    > Im doing something really stupid here, But I cant see the wood for the
    > trees. This is some of the code for my custom composite control. It
    > renders
    > fine and the buttons do cause a Post to occur. But the Click Handlers are
    > not are never receiving a click event. I note that the name of the control
    > is _ctl0 or 1 etc.
    >
    > <span id="MyDamnButton1" style="width:192px;Z-INDEX: 101; LEFT: 16px;
    > POSITION: absolute; TOP: 24px"><input type="submit" name="_ctl0"
    > value="Submit Me" /><input type="submit" name="_ctl1" value="Submit Me 2"
    > /></span>
    >
    > What could I have done wrong ?
    >
    > ------------------------
    >
    > Protected btnSubmit As New System.Web.UI.WebControls.Button
    > Protected btnSubmit2 As New System.Web.UI.WebControls.Button
    >
    > Protected Overrides Sub CreateChildControls()
    > btnSubmit.Text = "Submit Me"
    > btnSubmit2.Text = "Submit Me 2"
    > Controls.Add(btnSubmit)
    > Controls.Add(btnSubmit2)
    >
    > AddHandler btnSubmit.Click, AddressOf Me.Click1Handler
    > AddHandler btnSubmit2.Click, AddressOf Me.Click1Handler2
    > End Sub
    >
    >
    > Private Sub Click1Handler(ByVal sender As System.Object, ByVal e As
    > System.EventArgs)
    > Dim a As Int16 = 0
    >
    > End Sub
    >
    > Private Sub Click1Handler2(ByVal sender As System.Object, ByVal e As
    > System.EventArgs)
    > Dim a As Int16 = 0
    > End Sub
    >
    > --
    > Best Regards
    >
    > The Inimitable Mr Newbie º¿º
    >
     
    Kevin Spencer, Nov 6, 2005
    #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. sleigh
    Replies:
    1
    Views:
    2,698
    sleigh
    Feb 12, 2004
  2. Harvey
    Replies:
    0
    Views:
    291
    Harvey
    Jul 18, 2004
  3. rodchar
    Replies:
    0
    Views:
    397
    rodchar
    Nov 26, 2007
  4. Chad
    Replies:
    0
    Views:
    233
  5. Mike

    Composite vs non composite Controls

    Mike, Mar 10, 2005, in forum: ASP .Net Web Controls
    Replies:
    4
    Views:
    268
    Sundararajan
    Mar 11, 2005
Loading...

Share This Page