Yup, sure. It's best if you modify the SetLink to accept the control as a
parameter
SetLink(Dim c As Control). That entire block of code can then be placed in a
module or global file so that it is callable from every page.
--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc
"Morten Snedker" <> wrote in message
news:...
>I have three web-controls (ascx) on my page, all containing graphics
> with a hyperlink. The information for these hyperlinks are stored in a
> database.
>
> On the Page_Load of each web-control I run the code below.
>
> What I can't figure out is if I can make it global, so that on each
> Page_Load I call the SetLinks procedure. Is this possible, given the
> content of SetLinks?
>
> Or should I consider a whole new approach?
>
> Sub SetLinks()
>
> Dim h As HyperLink
> Dim c As Control
>
> Dim da As New DataAccess
> Dim reader As SqlDataReader = da.AdList
>
> Try
> If reader.HasRows Then
> While reader.Read
> c = FindControl(reader(1).ToString)
> If Not c Is Nothing Then
> h = CType(c, HyperLink)
> h.NavigateUrl = reader(2).ToString
> h.Text = reader(3).ToString
> h.Target = reader(4).ToString
> End If
> End While
> End If
> Catch ex As Exception
> Response.Write(ex.Message)
> 'don't throw exception to user
> 'this should be handled through admin-part
> Finally
> reader.Close()
> da.Close()
> End Try
>
> End Sub
>
>
> Regards /Morten