使用网页模板
我们有一个相当大的公共网站,最近用新的布局重新设计了它。现在的问题是,通过重新设计,我们发现自己不断地对所有页面的 html 布局进行硬编码。这显然不是最好的解决方案。
我的问题是,在某种意义上,共享/继承 Web 模板的方法有哪些选项,我们所有的 ASP.Net 项目都可以从中提取布局。特别是布局的 HTML 部分。对此模板所做的任何更改都会更新所有使用它的网站。我确信这种情况存在,但不知道如何处理它。
We have a fairly large public website and have recently redsigned it with a new layout. The problem now is that with our redesign we find ourselves constantly hardcoding the html layout for all of our pages. This is clearly not the best solution.
My question is what are some options on ways to share/inherit, in a sense, a web template that all our ASP.Net projects can pull from for the layout. Specifically the HTML side of the layout. Any changes made to this template will update all web sites that use it. I'm sure this exists but do not know how to approach it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
母版页就是您正在寻找的。请参阅:http://www.asp.net/master-pages/tutorials
或 http:// www.asp.net/master-pages/tutorials/creating-a-site-wide-layout-using-master-pages-vb
这就是技术解决方案。通常,改造用大量一次性构建的网站时面临的更大挑战是确定页面的哪些部分属于母版页或内容区域。请记住,您可以拥有多个内容区域,并且可以在母版页中提供默认内容,稍后可以在内容页中覆盖这些默认内容。它非常灵活。玩得开心!
Master Pages is what you are looking for. See: http://www.asp.net/master-pages/tutorials
or http://www.asp.net/master-pages/tutorials/creating-a-site-wide-layout-using-master-pages-vb
That's the technical solution. Oftentimes, the bigger challenge in retrofitting sites that were built with numerous one-offs is determining which parts of your pages belong in the master page or content areas. Keep in mind that you can have multiple content areas and you can provide default content in a master page that can later be overriden in a content page. It's very flexible. Have fun!
我知道的最简单的方法是为每个页面创建一个页眉和页脚文件。在
标记之后包含页眉,在
之前包含页脚。你的内容介于两者之间。
我更喜欢使用像 Smarty 这样的模板系统的更复杂的方法,但这就是 PHP。我不知道你的 ASP 选项是什么。
The simplest approach I know is to create a header and footer file for every page. Include the header just after the
<body>
tag and the footer just before</body>
. You content goes in between.I prefer a more sophisticated approach with a templating system like Smarty, but that's PHP. I don't know what your ASP options are.