473,498 Members | 2,058 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Master pages with a onload command.

I have a master page with stuff in it. It includes the body tag and then the
asp:content tag. I want to hide some text when the page is loaded but is
made visible by a check box. All that code works fine. I have the text in a
<divthat I hide/unhide when a checkbox is clicked and it's all done at the
client level.

Problem is, to hide the text I need to call a javascript function on load.
The only place it seems to work is in the <bodycommand. But if I do that,
I get a warning about having a <bodycommand within a <divcommand (the
div is part of my master page.)

Anyway around this? I would like to leave the stuff at the client side so it
responds immediately without a postback to the server.

TIA - Jeff.
Aug 14 '07 #1
4 3991
Move the <bodyto the master page outside the div. You can always set up
the <body>'s attributes from the content page. Is it what you are after?

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Mufasa" <jb@nowhere.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>I have a master page with stuff in it. It includes the body tag and then
the asp:content tag. I want to hide some text when the page is loaded but
is made visible by a check box. All that code works fine. I have the text
in a <divthat I hide/unhide when a checkbox is clicked and it's all done
at the client level.

Problem is, to hide the text I need to call a javascript function on load.
The only place it seems to work is in the <bodycommand. But if I do
that, I get a warning about having a <bodycommand within a <divcommand
(the div is part of my master page.)

Anyway around this? I would like to leave the stuff at the client side so
it responds immediately without a postback to the server.

TIA - Jeff.


Aug 14 '07 #2
How do I set the attribute on the body tag?

Do I put a runat="server" and then add the attributes in the Page_Load
routine?

J.

"Eliyahu Goldin" <RE**************************@mMvVpPsS.orgwrote in
message news:OS**************@TK2MSFTNGP06.phx.gbl...
Move the <bodyto the master page outside the div. You can always set up
the <body>'s attributes from the content page. Is it what you are after?

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Mufasa" <jb@nowhere.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>>I have a master page with stuff in it. It includes the body tag and then
the asp:content tag. I want to hide some text when the page is loaded but
is made visible by a check box. All that code works fine. I have the text
in a <divthat I hide/unhide when a checkbox is clicked and it's all done
at the client level.

Problem is, to hide the text I need to call a javascript function on
load. The only place it seems to work is in the <bodycommand. But if I
do that, I get a warning about having a <bodycommand within a <div>
command (the div is part of my master page.)

Anyway around this? I would like to leave the stuff at the client side so
it responds immediately without a postback to the server.

TIA - Jeff.



Aug 14 '07 #3
Take a look at the RegisterStartupScript method. Use that or declaratively
add your javascript call to the onload event with "window.onload = {name of
function, no parentheses}" Then it doesn't matter where your <bodytag is.

"Mufasa" <jb@nowhere.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>I have a master page with stuff in it. It includes the body tag and then
the asp:content tag. I want to hide some text when the page is loaded but
is made visible by a check box. All that code works fine. I have the text
in a <divthat I hide/unhide when a checkbox is clicked and it's all done
at the client level.

Problem is, to hide the text I need to call a javascript function on load.
The only place it seems to work is in the <bodycommand. But if I do
that, I get a warning about having a <bodycommand within a <divcommand
(the div is part of my master page.)

Anyway around this? I would like to leave the stuff at the client side so
it responds immediately without a postback to the server.

TIA - Jeff.


Aug 14 '07 #4
Yes, add runat="server". Also, give the body tag a unique id and then you
can refer it in the code-behind as
HtmlGenericControl myBodyTag.

And yes, you can add attributes in the Page_Load.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Mufasa" <jb@nowhere.comwrote in message
news:u5**************@TK2MSFTNGP05.phx.gbl...
How do I set the attribute on the body tag?

Do I put a runat="server" and then add the attributes in the Page_Load
routine?

J.

"Eliyahu Goldin" <RE**************************@mMvVpPsS.orgwrote in
message news:OS**************@TK2MSFTNGP06.phx.gbl...
>Move the <bodyto the master page outside the div. You can always set up
the <body>'s attributes from the content page. Is it what you are after?

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Mufasa" <jb@nowhere.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>>>I have a master page with stuff in it. It includes the body tag and then
the asp:content tag. I want to hide some text when the page is loaded but
is made visible by a check box. All that code works fine. I have the text
in a <divthat I hide/unhide when a checkbox is clicked and it's all
done at the client level.

Problem is, to hide the text I need to call a javascript function on
load. The only place it seems to work is in the <bodycommand. But if I
do that, I get a warning about having a <bodycommand within a <div>
command (the div is part of my master page.)

Anyway around this? I would like to leave the stuff at the client side
so it responds immediately without a postback to the server.

TIA - Jeff.




Aug 14 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1132
by: Mafuba | last post by:
I'm trying to use data sources with data bound controls on one of my pages that's using a master page. The master page has 2 ContentPlaceHolders, and in my page the data sources are in the first...
5
2397
by: Michael Herman \(Parallelspace\) | last post by:
1. What are some compelling solutions for using Master/Content pages with Web Pages? 2. If a content area has a web part zone with web parts, what is the user experience like when "editting" the...
17
3133
by: Rob R. Ainscough | last post by:
Again another simple concept that appears NOT to be intuitive or I'm just stupid. I've read the WROX book and the example doesn't actually show how the .master page links in the other content...
17
4590
by: MeerkatInFrance | last post by:
There comes a time when you know you are not going to be able to work something out yourself, however hard you try. I have reached that moment. I have a master page and a slave page (or whatever...
8
6661
by: JT | last post by:
Hi, I have done a fair amount of style editing inline in ASP. I'm now using VS 2005 with a standard web project (not Web Application Project). This is my first foray into CSS in a style sheet...
1
1124
by: Luminari | last post by:
I have two pages. Both of them are supposed to have one table on it with a fixed header. Both pages were tested in IE6. Structurally they are identical. Both have a <divthat wraps a <tablethat...
12
1621
by: Tim Wallace | last post by:
I have a windows 2000 server on which I have installed the .NET 2.0 Framework runtime. I have an application I've written using VS 2005. In it, I use master pages. When I debug this app on my...
1
1150
by: DaveRook | last post by:
Hi I am using a master page for my web project, and it's all coded in C# (and it works). Within one of the pages I want to run some server sided code. I have added a button and double clicked it...
3
2329
by: tshad | last post by:
In VS 2005, I need to get access to the body tag which I have set up on my Master Page as: <body ID="MyBody" runat="server"> But when do something like: ...
0
6993
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7162
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6881
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5456
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4584
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1411
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
287
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.