Web User Control Problem

R

Roshawn

Hi,

I have created a web user control that acts as a numeric pager on my page.
It consists of a repeater controls and an HtmlAnchor control. Of course the
HtmlAnchor is placed in the repeater's ItemTemplate template.

In the web user control I've created an event named PagerClick. What I'm
trying to do is pass the HtmlAnchor's InnerText to the page that contains
the web user control so further processing can be done. Here's my code:

Public Class SelectedAnchorEventArgs
Inherits EventArgs
Public Text As String
End Class

Public MustInherit Class NumericPager
Inherits System.Web.UI.UserControl
Protected WithEvents Repeater2 As System.Web.UI.WebControls.Repeater
Event PagerClick(ByVal sender As Object, ByVal e As
SelectedAnchorEventArgs)

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

End Sub

Public Function PagerNumbers() As ArrayList
'code implementation omitted, though it works great
End Function

Public Sub BindPager(ByVal arr As ArrayList)
With Me.Repeater2
.DataSource = arr
.DataBind()
End With
End Sub

Public Sub Pager_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim eventinfo As New SelectedAnchorEventArgs()
eventinfo.Text = CType(sender, HtmlAnchor).InnerText
RaiseEvent PagerClick(Me, eventinfo)
End Sub
End Class

Here is my code on the host page that uses the PagerClick event of the web
user control:

Private Sub NPager_Click(ByVal sender As Object, ByVal e As
SelectedAnchorEventArgs)
Handles NPager.PagerClick
Me.ViewState("page") = e.Text
Call GetKeywordData()
End Sub

I don't know why, but the procedure on the host page doesn't work. I've
tried modifying the attributes of the HtmlAnchor. I'm not sure if I'm to
override its OnServerClick method to get things to work. I've tried
everything else, but no success.

So I've come to feet of the great ASP.NET programmers out there. Can anyone
point me in the right direction? I've been toying with this for about 4hours
now. Any help will be greatly appreciated.

Thanks,
Roshawn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top