Making a public property in a master page is not visible in .aspxpage

D

DotNetNewbie

Hi,

I have a .aspx page that has a master page.

In the master page, I have a Literal Control, and I created a public
property that allows you to set the liBlah.Text of the literal
control.

The idea was that the .aspx page could simple use the property to set
the value of the literal, but for some reason the property is not
showing up in the intellisense of the .aspx page.

Did I do something wrong?

Do I have to use a findcontrol or somethign?
 
N

NvrBst

Hi,

I have a .aspx page that has a master page.

In the master page, I have a Literal Control, and I created a public
property that allows you to set the liBlah.Text of the literal
control.

The idea was that the .aspx page could simple use the property to set
the value of the literal, but for some reason the property is not
showing up in the intellisense of the .aspx page.

Did I do something wrong?

Do I have to use a findcontrol or somethign?

Add the following page directive to the top of the page your trying to
access your master page from.

<%@ MasterType virtualPath="~/myMasterPageName.master" %>

Now you should be able to access all your maspter page properties and/
or methos via "Master.Method()" etc.

NB
 
O

Onawole Clement Oladapo

Both method suggested by NvrBst and Samuel works. I'll suggest you use
NvrBst's suggestion, I always prefer that cos it's type safe and you can
escape runtime issues.
 
D

DotNetNewbie

Both method suggested by NvrBst and Samuel works. I'll suggest you use
NvrBst's suggestion, I always prefer that cos it's type safe and you can
escape runtime issues.

My page is already referencing the master page.

This is how it does it, in the codebehind instead of inheriting from
system.web.ui.page I inherit from MyCustomPage

And in MyCustomPage I set the masterpage.

That should be the exact same as if I was using the directive <%@ %>
tag right?
 

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

Top