Calling Event Handlers Inside Custom Control

Discussion in 'ASP .Net' started by mike.gilmore@jccteam.com, Feb 2, 2006.

  1. Guest

    Hi,

    I've created a custom control that contains a collection of link
    buttons (PagingControl.vb). I want an event to fire when the link
    button is clicked.

    The event handler is located in my primary asp.net file
    (ShowData.aspx). However, when I attempt to compile my class file, I
    get an error because the event the link button is attempting to wire to
    doesn't exist.

    Unfortunately, my fix isn't as simple as moving my event handler from
    ShowData.aspx to the class because that function class another function
    local to the page.

    Ideally I want my PagingControl.vb file to become part of my control
    library and accessible to all of my different web applications. The
    abbreviated code for the two files is shown below.

    Thanks in advance,

    Mike

    ShowData.aspx

    Public Sub ChangePage(Sender as Object, e as CommandEventArgs)
    lblClickValue = "It worked! " & e.CommandArgument
    End Sub
    <Paging:pagingControlLabel
    id="lblPaging"
    width="100%"
    Runat="Server"/>

    <br/>

    <asp:Label
    id="lblClickValue"
    runat="server"/>

    PagingControls.vb

    Dim objLb as LinkButton

    For loop = start_page to end_page

    objLb = New LinkButton
    objLb.Text = loop
    objLb.CommandName = "lb" & loop
    objLb.CommandArgument = loop

    addHandler objLb.Command, AddressOf ChangePage

    Next
    , Feb 2, 2006
    #1
    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. Jonah Olsson
    Replies:
    1
    Views:
    562
    Scott Allen
    Apr 5, 2005
  2. Dood
    Replies:
    1
    Views:
    612
  3. Nik Coughlin
    Replies:
    19
    Views:
    765
    Julian Turner
    Dec 18, 2009
  4. Jonah Olsson
    Replies:
    2
    Views:
    188
    Jonah Olsson
    Apr 5, 2005
  5. Nik Coughlin
    Replies:
    22
    Views:
    334
    Julian Turner
    Dec 18, 2009
Loading...

Share This Page