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

F

Frank

From: "Frank" <[email protected]>
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.

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="contests.aspx.cs" AutoEventWireup="false"
Inherits="MZ.contests" %>
<%@Register TagPrefix="mz" Tagname="HeadSection"
Src="mzControls/HeadSection.ascx" %>

<mz:HeadSection runat="server" />

<body>
..
..
..
..
</body>


And in the custom control:

objTextWriter.RenderBeginTag( "Head" ); objTextWriter.RenderBeginTag(
"Title" );objTextWriter.Write( "Title");objTextWriter.RenderEndTag();
objTextWriter.RenderBeginTag( "meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1" );objTextWriter.RenderEndTag();
objTextWriter.RenderBeginTag( "LINK href="/common/css/stylesheet.css"
type="text/css" rel="stylesheet");objTextWriter.RenderEndTag();
objTextWriter.RenderBeginTag( "script language="JavaScript"
src="common/js/global.js"
type="text/JavaScript" );objTextWriter.RenderEndTag();
objTextWriter.RenderEndTag();


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



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

Frank K.
 
C

chris martin

From: "Frank said:
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.

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="contests.aspx.cs"
AutoEventWireup="false"
Inherits="MZ.contests" %>
<%@Register TagPrefix="mz" Tagname="HeadSection"
Src="mzControls/HeadSection.ascx" %>
<mz:HeadSection runat="server" />

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

objTextWriter.RenderBeginTag( "Head" ); objTextWriter.RenderBeginTag(
"Title" );objTextWriter.Write( "Title");objTextWriter.RenderEndTag();
objTextWriter.RenderBeginTag( "meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1"
);objTextWriter.RenderEndTag();
objTextWriter.RenderBeginTag( "LINK
href="/common/css/stylesheet.css"
type="text/css" rel="stylesheet");objTextWriter.RenderEndTag();
objTextWriter.RenderBeginTag( "script language="JavaScript"
src="common/js/global.js"
type="text/JavaScript" );objTextWriter.RenderEndTag();
objTextWriter.RenderEndTag();

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

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

Frank K.

You're already using a user-control so, unless you really want/need to programmatically
render those tags, I would just put the HTML in the ascx file.

Chri
 
F

Frank K

Yes...I see that now. I overcomplicated it.

I just had a hard time imagining that you could insert the control in
the head section....

This is because I thought ALL controls had to be inserted within the
<form></form> tags. Guess I was wrong.

Thanks for the help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top