473,395 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Output literal to documents HEAD and BODY tags.

Is there any way to, from the page class, send literal output to the <HEAD>
of te page, or within the <BODY onload="('theFunctionIAddedToTheHead');"> ?
I need to do this in a class that inherrits from PAGE, but is an abstract
class for the pages of my site. I.E.

System.Web.UI.Page -> myBasePage

All pages in the site inherit from myBasePage, and will be able to use
funciton is myBasePage to modify content in the HEAD tag.

I've looked into inherriting from a class that totally overrides the base
pages' render method, but this is, quite honestly, a little scary to me
because it require re-creating the form entirely.

Ideas are greatly appreciated!
tnx

D
Nov 18 '05 #1
2 1321
Typically, to render HTML to the <HEAD> or <BODY> tags, or any other tag
that sits outside of a WebForm, you would do 2 things:

1. Add runat=server and an id to the tag in the Page Template
2. Add the CodeBehind class (HtmlGenericControl) to the CodeBehind.

The Page Template is incomplete without the CodeBehind class from which it
is derived. The problem in your case is that if you want these to be in an
inherited class, you're still going to have to add them in manually to each
Page Template that uses the CodeBehind. Although this would be a bit dodgy,
I believe it would work. Since it has to be added to each Page Template in
any case, an alternative would be to simplify your inherited Page class to
leave this out, and add it only to the Pages that need it.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Big D" <a@a.com> wrote in message
news:OP*************@TK2MSFTNGP10.phx.gbl...
Is there any way to, from the page class, send literal output to the <HEAD> of te page, or within the <BODY onload="('theFunctionIAddedToTheHead');"> ? I need to do this in a class that inherrits from PAGE, but is an abstract
class for the pages of my site. I.E.

System.Web.UI.Page -> myBasePage

All pages in the site inherit from myBasePage, and will be able to use
funciton is myBasePage to modify content in the HEAD tag.

I've looked into inherriting from a class that totally overrides the base
pages' render method, but this is, quite honestly, a little scary to me
because it require re-creating the form entirely.

Ideas are greatly appreciated!
tnx

D

Nov 18 '05 #2

Hi,

Thanks for posting in this group.
Just Kevin said, you can make your body tag into a HtmlGenericControl, then
you can manipulate it in code behind.
Like this:

<body MS_POSITIONING="GridLayout0" runat="server" id="bodyid"> //In html
view

//In Code behind
protected System.Web.UI.HtmlControls.HtmlGenericControl bodyid;

private void Page_Load(object sender, System.EventArgs e)
{
bodyid.Attributes.Add("bgcolor","red");
}

Then your body tag will be added bgcolor attribute after render. You also
can add event handler through this way.

Hope this helps,

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 18 '05 #3

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

Similar topics

6
by: Pjotr Wedersteers | last post by:
Hi, When I include a script in my html I don't get any output back in the calling page. The script is on a remote location for the html page. Example given: myscript.php: <?PHP echo...
4
by: Jan K. | last post by:
Hi there, I have edited some php-source (a Stringychat 'shoutbox' on the webpage) By default, all the text was not marked up at all. I have tried to markup the text, and succeeded partly. Can...
1
by: Lisa | last post by:
I need to apply the HTML formatting tags and the French accented characters in a XML document. The XML is generated from a database that has HTML tags and French accented characters in the records....
3
by: Steffen Beyer | last post by:
Hi, my XSLT processes input documents which use various namespaces. Short example: XML input: <news:foo xmlns:news="http://some.example/news"/>
5
by: Poster | last post by:
I have a script, its outputs are in HTML. It displays perferctly in a browser, however when I view source, it gives me the JS scripts, but I want to view the HTML output. Is there a way I can view...
1
by: Sujay | last post by:
Hello , I have an html file which contains link to 4 reports ( html files ). Instead of letting the user open one link at a time, and then printing the report , I want to print all the reports...
6
by: Wescotte | last post by:
I'm writing a tiny php app that will log into our bank of america account and retrieve a file containing a list of checks that cleared the previous day. The problem I'm running into is when I...
9
by: Steve Peterson | last post by:
Hi I have an .aspx web form in which I would like to output only XML, no HTML. The datasource is a datatable that's bult on the fly based on user input from previous .aspx page so the XML output...
3
by: Water Cooler v2 | last post by:
Questions: 1. Can there be more than a single script block in a given HEAD tag? 2. Can there be more than a single script block in a given BODY tag? To test, I tried the following code. None...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.