Thursday, March 22, 2012

setting the Master page of an existing form

Hi,

If I have created a web form, then create the Master Page, how can I set a
reference to that Master page from my web form?

Many thanks for any answers

Ant"Ant" <Ant@.discussions.microsoft.comwrote in message
news:D702490D-92AE-4E26-9DE4-C53FD271D708@.microsoft.com...

Quote:

Originally Posted by

If I have created a web form, then create the Master Page, how can I set a
reference to that Master page from my web form?


this.Master......

--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Thanks Mark,

I added this to my Page Load event:

this.Master = "MasterPage.master";

but got a compile error saying that the property was read only.

Could you perhaps give me a bit more information regarding this & also, is
it possible to do this via the properties box?

Many thanks for your help with this

Cheers

Ant

"Mark Rae [MVP]" wrote:

Quote:

Originally Posted by

"Ant" <Ant@.discussions.microsoft.comwrote in message
news:D702490D-92AE-4E26-9DE4-C53FD271D708@.microsoft.com...
>

Quote:

Originally Posted by

If I have created a web form, then create the Master Page, how can I set a
reference to that Master page from my web form?


>
this.Master......
>
>
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
>
>


"Ant" <Ant@.discussions.microsoft.comwrote in message
news:7081D687-00B9-4C02-A4AE-30791454420B@.microsoft.com...

Quote:

Originally Posted by

Could you perhaps give me a bit more information regarding this & also, is
it possible to do this via the properties box?


What are you actually trying to do?

Your OP said you want to "set a reference" to the MasterPage from the
content page...

E.g. to refer to a control on the MasterPage, you'd use something like:

MasterPageTextBox TextBox = (TextBox)this.Master.FindControl("MyTextBox");

Is that not what you meant...?

--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Apologies for the misunderstanding,

When I said reference, I meant how to 'associate' a web form with a
particular master page. I believe the above poster answered the question.

Many thanks though

Ant

"Mark Rae [MVP]" wrote:

Quote:

Originally Posted by

"Ant" <Ant@.discussions.microsoft.comwrote in message
news:7081D687-00B9-4C02-A4AE-30791454420B@.microsoft.com...
>

Quote:

Originally Posted by

Could you perhaps give me a bit more information regarding this & also, is
it possible to do this via the properties box?


>
What are you actually trying to do?
>
Your OP said you want to "set a reference" to the MasterPage from the
content page...
>
E.g. to refer to a control on the MasterPage, you'd use something like:
>
MasterPageTextBox TextBox = (TextBox)this.Master.FindControl("MyTextBox");
>
Is that not what you meant...?
>
>
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
>
>

0 comments:

Post a Comment