Accessing MasterPage Properties from a usercontrol on a contentpage??

W

wildman

RE: Accessing MasterPage Properties from a usercontrol on a
contentpage??


On my master page's codebehind I have this property:


Public Property ErrorMsg() As String
Get
Return ErrorLabel.Text
End Get
Set(ByVal value As String)
ErrorLabel.Text = value
End Set
End Property


I've got this on the contentpage,


<%@ MasterType VirtualPath="ShapeUp.master" %>


and I confirmed I can can set the property from the content page.

However on my content page, I have a user control

From inside that user control, I can see all the other properties from
Page.Master , but not ErrorMsg I created on the master page
codebehind.

Also, I've tried this, but it does not work

Dim errorMsg As Label = CType(Page.Master.FindControl("ErrorMsg"),
Label)
errorMsg.Text = "xxxx"

Do I have no choice but to code event handling?


Thanks for any help or information.
 
M

Masudur

RE: Accessing MasterPage Properties from a usercontrol on a
contentpage??

On my master page's codebehind I have this property:

Public Property ErrorMsg() As String
Get
Return ErrorLabel.Text
End Get
Set(ByVal value As String)
ErrorLabel.Text = value
End Set
End Property

I've got this on the contentpage,

<%@ MasterType VirtualPath="ShapeUp.master" %>

and I confirmed I can can set the property from the content page.

However on my content page, I have a user control

From inside that user control, I can see all the other properties from
Page.Master , but not ErrorMsg I created on the master page
codebehind.

Also, I've tried this, but it does not work

Dim errorMsg As Label = CType(Page.Master.FindControl("ErrorMsg"),
Label)
errorMsg.Text = "xxxx"

Do I have no choice but to code event handling?

Thanks for any help or information.

Hi...

did you tried casting the Page.Master to your class
code in c# will look like this
string msg = (Page.Master as ShapeUp).ErrorMsg;

Masudur
www.munna.shatkotha.com
www.shatkotha.com
 
W

wildman

Thanks. I tried this, but it never set the property on the master's
ErrorMsg.

Dim msg As String = TryCast(Page.Master, Master_Shapeup).ErrorMsg
msg = "WTF"

Note: If I simply do

Master.ErrorMsg from the contentpage where the control lives it sets
it.

Am I going to have to do this with event handling? If so, I'm not sure
how.
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top