内置 ASP.net 4.0 Webform 控件可以输出 HTML5 吗?

发布于 2024-12-18 16:02:10 字数 300 浏览 5 评论 0原文

我们正在努力做好准备并支持 HTML5。

我相信asp.net 4.0中的内置Web控件输出XHTML。

据我了解,内置控件尚未输出 HTML5,但是它们是否可以输出 HTML4?

我并不是特别想输出 HTML / XHTML 的混合匹配,因为虽然我确信大多数浏览器都会处理它,但这似乎是一种会带来不好的意外的方法。

据我了解,浏览器对 XHTML5 的支持不是很好(尽管我仍在研究这一点)。

这个想法是,周围的 HTML 可以使用 HTML5,而控件暂时只使用 HTML4,直到 ASP.NET 赶上来?

We're looking to gear up and support HTML5.

I believe that the built-in web controls in asp.net 4.0 output XHTML.

From what I understand the built-in controls do not yet ouput HTML5, however is it possible from them to output HTML4?

I don't particulary want to output a mixmatch of HTML / XHTML as although I'm sure most browsers will just deal with it, it seems like an approach that will have bad surprises.

From what I understand, XHTML5 support isn't great in browsers (though I'm still researching that).

The idea being that the surrounding HTML can make use of HTML5 and the controls just use HTML4 for the moment until asp.net catches up?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

氛圍 2024-12-25 16:02:10

支持 HTML5 输出:

要使 HTML5 功能在 Web 表单或视图中正常工作,您需要将 替换为其 HTML5 对应项。在 ASP.NET Web 窗体中,此代码属于母版页。在 ASP.NET MVC 中,此代码属于 _Layoutpage.cshtml 布局页面。
无论文件类型如何,标记都是相同的,如下所示:

<!DOCTYPE html>
<html>

XHTML5 支持很容易使用文档类型、命名空间和一些样式来添加:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
        <meta charset="utf-8"/>

        <meta name="description" content="XHTML example for styling HTML5 elements in Internet Explorer without Javascript using namespaces."/>
        <meta name="author" content="Elco Klingen"/>
        <meta name="copyright" content="Copyright (c) 2010 Elco Klingen"/>

        <title>HTML5 elements in Internet Explorer without Javascript - XHTML Example</title>

        <style>
            .section, section, html5\:section {
                display: block;
                padding: 0 75px;
                border: 5px solid #e6e6e6;
                background: #cfc;
            }
        </style>
    </head>

    <body>
        <html5:section>foo</html5:section>
        <section>bar</section>
        <!--...-->
    </body>
</html>

HTML5 output is supported:

For HTML5 features to work properly in Web Forms or views, you need to replace <!DOCTYPE> and <html> with their HTML5 counterparts. In ASP.NET Web Forms, this code belongs in the master page. In ASP.NET MVC, this code belongs in the _Layoutpage.cshtml layout page.
Regardless of the file type, the markup is the same, as demonstrated here:

<!DOCTYPE html>
<html>

XHTML5 support is simple to add using a doctype, namespacing and some styles:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
        <meta charset="utf-8"/>

        <meta name="description" content="XHTML example for styling HTML5 elements in Internet Explorer without Javascript using namespaces."/>
        <meta name="author" content="Elco Klingen"/>
        <meta name="copyright" content="Copyright (c) 2010 Elco Klingen"/>

        <title>HTML5 elements in Internet Explorer without Javascript - XHTML Example</title>

        <style>
            .section, section, html5\:section {
                display: block;
                padding: 0 75px;
                border: 5px solid #e6e6e6;
                background: #cfc;
            }
        </style>
    </head>

    <body>
        <html5:section>foo</html5:section>
        <section>bar</section>
        <!--...-->
    </body>
</html>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文