To turn of the pagination when switching between the design and HTML
view, do the following:

Tools | Options | Text Editor | HTML/XML | HTML Specific | uncheck
Enable HTML validation.

Then the "runat=server" will be maintained.


-----Original Message-----
From: dotnet discussion [mailto:[EMAIL PROTECTED]] On Behalf Of
Collins, Michael G
Sent: Thursday, May 23, 2002 12:01 PM
To: [EMAIL PROTECTED]
Subject: [DOTNET] How to insert into the Head, Title, Style, Script tags

OK. I know that this has been discussed, but I have not been able to
find a
good explanation of this yet. The archives are not easy to search.

I want to be able to update the content of the <head></head> tag or the
<title></title> tag or the <script></script> tag from down within my
page.

I have a custom control that can dig down into the DOM on the server
side,
but I can't seem to get it to make any changes that seem to take affect
and
I can't get any of it to work without setting the runat="server"
attribute
for the tags I want to change.

The next problem is that the editor (VS.NET) likes to remove the
runat="server" attribute for any tag that DS feels should not have the
attribute.


So my questions are:

Question 1:
Is there a way to access a general HTML tag on the server? I need to be
able
to change the InnerHtml for the tag and have it show up on the browser.
Right now I am trying to use the Render(HtmlTextWriter output) function:

Page p = this.Page;
bool found = false;
foreach( Control control in p.Controls )
{
        if( found )
                break;

        if( control as HtmlGenericControl != null )
        {
                if( ((HtmlGenericControl)control).TagName.ToUpper()
=="HEAD"
)
                {
                        found = true;
                        string newStr = "\r\n<title>"+title+"</title>" +
((HtmlGenericControl)control).InnerHtml;
                        ((HtmlGenericControl)control).InnerHtml +=
newStr;
                }
        }
}

The InnerHtml has the data I want, but when I change it nothing passes
through to the browser. Do I need to do this before the Render()
function or
somewhere else?

Also this will ONLY work if I set runat="server" for the <head> tag.

So Question 2:
Is there a way to change what VS.NET deems correct HTML? Is there a
template
somewhere that I can change to allow runat="server" to be OK for the
tags I
want?


BTW: Microsoft might want to conceder making the entire DOM available on
the
server side in a similar fashion to the way IE6 sees the DOM on the
client
side. That way we can adjust the DOM before it gets sent to the browser.
(Maybe there is a way to do this, but I can't find it.)

Thanks in advance,
Mike Collins

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