I saw the question and started writing my own sample code.  I posted the
Extracting the Title of a Page from CodeBehind?" earlier in the month.

I know you figured it out but I can't waist my sample so here it is:

I use the PreRender of page to add a meta tag.  You could put this in
your base page.


private void ShowControls_PreRender(object sender, System.EventArgs e)
{
        foreach (Control control in Controls)
        {
          if (control as System.Web.UI.LiteralControl != null )
            {
                if
(((System.Web.UI.LiteralControl)control).Text.ToUpper().IndexOf("<HEAD>"
) > -1)
                  {
                  //parse out the title.
string literal = (System.Web.UI.LiteralControl)control).Text.ToUpper();
int startTitleOpenPos = literal.IndexOf("<HEAD>");

((System.Web.UI.LiteralControl)control).Text =

((System.Web.UI.LiteralControl)control).Text.Insert(startTitleOpenPos +
6,"<meta (joe.net)/>");
                }
           }
        }
}





-----Original Message-----
From: dotnet discussion [mailto:[EMAIL PROTECTED]] On Behalf Of
Kirk Jackson
Sent: Wednesday, May 15, 2002 9:51 PM
To: [EMAIL PROTECTED]
Subject: Re: [DOTNET] ASP.NET Control - Insert text in
<HEAD>here!</HEAD>?

It's probably possible to extract the literal controls for the head tag,
and replace them - see the thread titled "Extracting the Title of a Page
from CodeBehind?" from the archives (early May)

Kirk

-----Original Message-----
From: Zane Thomas [mailto:[EMAIL PROTECTED]]
Sent: Thursday, 16 May 2002 4:45 p.m.
To: [EMAIL PROTECTED]
Subject: Re: [DOTNET] ASP.NET Control - Insert text in
<HEAD>here!</HEAD>?


Dan,

> Could you have the control write the entire header-delete whatever is
> in the page and put it in the control?

I haven't been able to figure out how to get to the <head>, otherwise I
might be able to modify it.  But I think it's generated on the fly, into
the Response's stream.  One approach that *might* work would be to
supply a stream to the HttpResponse.Filter property and wait for </head>
to arrive - inserting the extra content there.   That's ugly, but if no
one has a better suggestion I'll give it a go.




> When the html for an aspx is output something, somewhere, inserts:
>
> <HEAD>
>    <meta (some of these)/>
> </HEAD>
> <body>
> </body>
>
> My control needs to write some stuff inbetween <head> and </head> ...
> does anyone know how to do that?
>
>
> Zane
>
> You can read messages from the DOTNET archive, unsubscribe from
> DOTNET, or subscribe to other DevelopMentor lists at
> http://discuss.develop.com.
>
> You can read messages from the DOTNET archive, unsubscribe from
> DOTNET, or subscribe to other DevelopMentor lists at
> http://discuss.develop.com.
>

You can read messages from the DOTNET archive, unsubscribe from DOTNET,
or subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET,
or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to