Accessing UserControl Property from Page

T

tdavisjr

Ok.. Here it goes.

I have a MasterPage that includes a UserControl (HeaderControl.ascx)
that has the ID of Header1 in the markup in the Master Page. Now, the
Head1 usercontrol has a property called Title.

Then, I have a Test.aspx page that uses the Masterpage and I want to be
able to acces the Title Property of the Header1 user control that is in
the MasterPage.

Here is what I am doing in the Page_Init in the Test.aspx:

Dim pageHeader As HeaderControl =
CType(Me.Master.FindControl("Header1"), HeaderControl)
pageHeader.Title = "Error"

This doesn't do anything. The title doesn't show up. Anyone have any
suggestions?
 
G

Guest

I have done this by using a label server control in the user-control that is
defined as "Public Shared WithEvents"
 
T

tdavisjr

Thanks. I have decided to do away with the header usercontrol and put
its content in the MasterPage itself. I was converting a 1.1 app to a
2.0 app and I figured I could take some shortcuts by re-using the
pre-existing usercontrols.
 
G

Guest

hmm...strange it should work. Make sure that the poperty in your user control
is not read only i.e it has both get and set.
 

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,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top