Accessing controls in a user control

  • Thread starter Thread starter Kay
  • Start date Start date
K

Kay

Hello,

I have a user control which I add to my page. The user control has a number
of hyperlinks. From within my page I want to access a particular hyperlink
and disable it, How do I do this?

Thanks,
Kay.
 
Kay said:
Hello,

I have a user control which I add to my page. The user control has a
number of hyperlinks. From within my page I want to access a
particular hyperlink and disable it, How do I do this?

Thanks,
Kay.

As an object oriented approach, I would suggest adding a method
to your user control to do just that.

Then, call that method from your page.
 
Yes that is a good idea, but I still do not know how to reference the
hyperlink control I want disabled. Assuming I have the following method in
the user control
Sub DisableHyperlink(ByVal hyperlinkToDisable As
System.Web.UI.WebControls.HyperLink)

hyperlinkToDisable.Enabled = False

End Sub

how do I reference from the aspx page, the hyperlink I want to disable, as
it is part of the user control?

Thanks,
Kay
 
Kay said:
Yes that is a good idea, but I still do not know how to reference the
hyperlink control I want disabled. Assuming I have the following
method in the user control
Sub DisableHyperlink(ByVal hyperlinkToDisable As
System.Web.UI.WebControls.HyperLink)

hyperlinkToDisable.Enabled = False

End Sub

how do I reference from the aspx page, the hyperlink I want to
disable, as it is part of the user control?

Me.FindControl("HyperlinkToDisableID").Enabled=False
 
Back
Top