473,790 Members | 2,421 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 4759
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
2044
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
5559
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
2502
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
9666
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
9512
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10413
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
10145
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,...
0
9021
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7530
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
5422
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...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3707
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.