Write to HTML Tag?

  • Thread starter Thread starter localhost
  • Start date Start date
L

localhost

I need to write an XML namespace declaration in my HTML tag. It must
be done in the code-behind for the page, I can't edit the .aspx
template directly.

I need to turn this:

<HTML>

into this:

<HTML XMLNS:MyNewSpace>


I have already added "id" and "runat" attributes to the <html> tag,
but now I need to address it and get text inside.

Thanks.
 
This might get you started:

<%@ Page language="c#" AutoEventWireup="false" Trace="false" %>
<!doctype html public "-//w3c/dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html lang="en" id="HTML" runat="server">
<head>
<script language="C#" runat="server">
protected override void OnLoad(EventArgs e)
{
HTML.Attributes["xmlns:foobar"] = "http://foobar.org/";
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="GENERATOR" content="Microsoft Visual Studio 7.0" />
<meta name="CODE_LANGUAGE" content="C#" />
</head>
<body>
<form id="Form1" method="post" runat="server">
Hello world
</form>
</body>
</html>


I need to write an XML namespace declaration in my HTML tag. It must
be done in the code-behind for the page, I can't edit the .aspx
template directly.

I need to turn this:

<HTML>

into this:

<HTML XMLNS:MyNewSpace>


I have already added "id" and "runat" attributes to the <html> tag,
but now I need to address it and get text inside.

Thanks.
 
Hi Localhost,

As for the question on add custom attributes into the <HTML> tag, I think
Scott 's suggestions i reasonable.
If you are using codebehind for your asp.net web page, in addition to add
the "id" and "runat" attrributes , you also need to declare a
HtmlGenericControl page member to map the <Html> tag, after that, you can
reference the <html> in your code, just as below:

<HTML id="MyHtml" runat="server">
<HEAD>

protected System.Web.UI.HtmlControls.HtmlGenericControl MyHtml;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
MyHtml.Attributes.Add("XMLNS","HTTP://LEARN");
}


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
localhost said:
I need to write an XML namespace declaration in my HTML tag. It must
be done in the code-behind for the page, I can't edit the .aspx
template directly.

I need to turn this:

<HTML>

into this:

<HTML XMLNS:MyNewSpace>


I have already added "id" and "runat" attributes to the <html> tag,
but now I need to address it and get text inside.

Sorry, you can't do this without touching the .aspx page. It would need to
have:

<HTML runat="server" id="myHtmlTag">

Only HTML elements marked with runat="server" have any existence on the
server.
 

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

Back
Top