Calling Event Handlers Inside Custom Control


M

mike.gilmore

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
 
Ad

Advertisements


Top