473,714 Members | 2,539 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can I Use HTML Text Writer i a Custom Control to Render the <head> Section?

I would like to create a custom control that generates everything that will
be in the <head> </head> section.

This would allow me to make changes on all pages withing a site in one
location.

But can I do so since the control would not be withing a <form> tag in the
aspx page?

Can I do like so?:

<%@ Page language="c#" Codebehind="con tests.aspx.cs" AutoEventWireup ="false"
Inherits="MZ.co ntests" %>
<%@Register TagPrefix="mz" Tagname="HeadSe ction"
Src="mzControls/HeadSection.asc x" %>

<mz:HeadSecti on runat="server" />

<body>
..
..
..
..
</body>
And in the custom control:

using System;

using System.Web;

using System.Web.UI;

namespace myControls

{

public class ShowHeadSection : Control

{

protected override void Render( HtmlTextWriter objTextWriter )

{

objTextWriter.R enderBeginTag( "Head" );

objTextWriter.R enderBeginTag(
"Title" );objTextWriter .Write( "Title");objTex tWriter.RenderE ndTag();

objTextWriter.R enderBeginTag( "meta
http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" );objTextWriter .RenderEndTag() ;

objTextWriter.R enderBeginTag( "LINK
href="/common/css/stylesheet.css" type="text/css"
rel="stylesheet ");objTextWrite r.RenderEndTag( );

objTextWriter.R enderBeginTag( "script language="JavaS cript"
src="common/js/global.js"
type="text/JavaScript" );objTextWriter .RenderEndTag() ;

objTextWriter.R enderEndTag();

}

}

}

NOTICE, I am also trying to render a meta tag, a link tag, and a script tag

Thanks in advance for any help ( Peter :o) )

Frank K.


Jan 18 '06 #1
1 4755
Frank,

Are you using ASP.NET 2.0 (.NET 2.0)? If so, you can use master pages
which will act as a template for all of your pages, which you can declare
the information in the head section of the returned HTML.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Frank" <fk******@pfmai l.com> wrote in message
news:uE******** ******@tk2msftn gp13.phx.gbl...
I would like to create a custom control that generates everything that will
be in the <head> </head> section.

This would allow me to make changes on all pages withing a site in one
location.

But can I do so since the control would not be withing a <form> tag in the
aspx page?

Can I do like so?:

<%@ Page language="c#" Codebehind="con tests.aspx.cs"
AutoEventWireup ="false" Inherits="MZ.co ntests" %>
<%@Register TagPrefix="mz" Tagname="HeadSe ction"
Src="mzControls/HeadSection.asc x" %>

<mz:HeadSecti on runat="server" />

<body>
.
.
.
.
</body>
And in the custom control:

using System;

using System.Web;

using System.Web.UI;

namespace myControls

{

public class ShowHeadSection : Control

{

protected override void Render( HtmlTextWriter objTextWriter )

{

objTextWriter.R enderBeginTag( "Head" );

objTextWriter.R enderBeginTag(
"Title" );objTextWriter .Write( "Title");objTex tWriter.RenderE ndTag();

objTextWriter.R enderBeginTag( "meta
http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" );objTextWriter .RenderEndTag() ;

objTextWriter.R enderBeginTag( "LINK
href="/common/css/stylesheet.css" type="text/css"
rel="stylesheet ");objTextWrite r.RenderEndTag( );

objTextWriter.R enderBeginTag( "script language="JavaS cript"
src="common/js/global.js"
type="text/JavaScript" );objTextWriter .RenderEndTag() ;

objTextWriter.R enderEndTag();

}

}

}

NOTICE, I am also trying to render a meta tag, a link tag, and a script
tag

Thanks in advance for any help ( Peter :o) )

Frank K.

Jan 18 '06 #2

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

Similar topics

2
2042
by: ryan.mclean | last post by:
Hello everyone. Hope ya'll had a nice New Year. Anyway, my question is why won't this work? I must be doing something dumb . . . here is the code: in the body tag, I have this code (just to test): <script LANGUAGE="javascript"> <!-- function hiThere() { alert("hi");
7
5553
by: Ignac Vucko | last post by:
Is writing a document *during* page load safe and supported for all 4th and 5th generation browsers? If not, can you show me a specific example/browser where it causes problems? <html> <head> <script>document.writeln("<div id='mydiv'>stuff</div>");</script> </head> <body>blah</body>
5
2499
by: Arne | last post by:
I need literal controls in the <head> section of my page. I need to be able to load dynamic values in the head section. It works fine in ASP.Net 1.1, but Asp.net 2.0 gives a compile error. I need the dynamically assigned <base href='??'> and <META NAME="Description" CONTENT="??"> Is there a work around?
2
529
by: Frank | last post by:
From: "Frank" <fkaesser@pfmail.com> Subject: Can I Use HTML Text Writer i a Custom Control to Render the <head> Section? Date: Wednesday, January 18, 2006 11:38 AM I would like to create a custom control that generates everything that will be in the <head> </head> section. This would allow me to make changes on all pages withing a site in one location.
0
8797
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9309
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9071
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6629
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5945
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4462
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3156
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 we have to send another system
2
2514
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2107
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.