Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to access ID in Master Page

0 views
Skip to first unread message

tshad

unread,
May 15, 2008, 1:13:20 PM5/15/08
to
I have the body tag of my page in my master page.

<body id="MyBody" runat="server">

In my control that is on the page, I want to set the onload event which I
would do if it was in my control but it isn't:

MyBody.Attributes.Add("onclick", "TestIt();");

Is there a way to do this from the control?

Doing this gives me the error:

Error 5 The name 'MyBody' does not exist in the current context

Thanks,

Tom


Peter Bromberg [C# MVP]

unread,
May 15, 2008, 1:44:50 PM5/15/08
to
Have you tried Page.FindControl("MyBody")? Or, Master.FindControl (whichever
the case may require)?
Peter

"tshad" <ts...@dslextreme.com> wrote in message
news:u1Dn67qt...@TK2MSFTNGP06.phx.gbl...

Madhur

unread,
May 16, 2008, 12:17:29 AM5/16/08
to
In the content page, include an @MasterType directive. This will cause the
.Master property to be automatically cast to the correct type so that you
can access any of it's methods and/or properties.
--
MAdhur

"tshad" <ts...@dslextreme.com> wrote in message
news:u1Dn67qt...@TK2MSFTNGP06.phx.gbl...

0 new messages