加入的&lt属性; HTML>在asp.net中的元素? [英] Add an attribute to the <HTML> element in asp.net?

查看:200
本文介绍了加入的&lt属性; HTML>在asp.net中的元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想两个额外的XML命名空间添加到< HTML> 在asp.net元素:

I would like to add two additional xml namespaces to the <HTML> element in asp.net:

看法:

<html xmlns="http://www.w3.org/1999/xhtml" >

做(加入Facebook的Open Graph的命名空间):

to make (adding facebook open graph namespaces):

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:og="http://ogp.me/ns#"
      xmlns:fb="http://www.facebook.com/2008/fbml">

我将如何访问&LT; HTML&GT; 后面code元素,并添加命名空间?

How would I access the <HTML> element in code behind and add a namespace?

推荐答案

您可以做到这一点,就像任何其他的元素。在你的aspx只是标记HTML标记为RUNAT服务器:

You can do it just like any other element. In your aspx just mark the html tag to be runat server:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" id="html_tag" runat="server">

而在你的code刚才添加的属性:

And in your code just add the attributes:

protected void Page_Load(object sender, EventArgs e)
{
   html_tag.Attributes.Add("xmlns:og","http://ogp.me/ns#");
   html_tag.Attributes.Add("xmlns:fb", "http://www.facebook.com/2008/fbmls");
}

这当然并不一定可以通过code完成,正好可以放置在你的aspx,除非你想只包括在一定条件下的属性。

This of course does not have to be done via code and can just be placed in your aspx unless you wanted to only include those attributes in certain conditions.

这篇关于加入的&lt属性; HTML&GT;在asp.net中的元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆