By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,962 Members | 1,430 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,962 IT Pros & Developers. It's quick & easy.

Accessing UserControl Property from Page

P: n/a
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?

Jan 3 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
I have done this by using a label server control in the user-control that is
defined as "Public Shared WithEvents"
Jan 3 '06 #2

P: n/a
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.

Jan 3 '06 #3

P: n/a
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.

"tdavisjr" wrote:
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?

Jan 3 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.