【问题标题】:Is there any control like contentplaceholder which is in asp.net for plain html是否有像 contentplaceholder 这样的控件,它在 asp.net 中用于纯 html
【发布时间】:2011-04-18 02:42:00
【问题描述】:

我有一些 HTML 页面,例如 example1.html、example2.html、example3.html 和 example4.html。所有页面都有相同的页眉、页脚和侧边栏。

如何制作一个复制其中任何一个的主模板,以避免在每个 HTML 页面中重复页眉和页脚代码?

我的服务器端将是用 c# 编码的 asmx Web 服务。

【问题讨论】:

    标签: asp.net html xhtml dhtml


    【解决方案1】:

    您需要在 ASP.NET WebForms 或 ASP.NET MVC 中使用 MasterPages。在 Master Page 系统中,您的公共标记进入单个页面(您的 MasterPage),然后 ContentPages 保存填充空白的唯一内容。

    【讨论】:

    • 如果我使用 contentplaceholder 控件,我的 html 页面必须保存为 example1.aspx,example2.aspx 但我希望我的 html 页面使用 .html 扩展名保存并编写服务器端代码
    【解决方案2】:

    不要认为母版页有纯 html 对应物。您可以拥有一个主 html 页面,其中包含在 iframe 中托管其他内容 html 的通用页眉页脚部分。

    【讨论】:

    • 使用 iframe 是最好的选择,或者在 Dreamweaver 中创建主模板是最好的选择。
    猜你喜欢
    • 1970-01-01
    • 2018-12-15
    • 2017-10-20
    • 1970-01-01
    • 1970-01-01
    • 2015-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多