Asp.Net MVC 主题,如何?

发布于 2024-07-18 02:47:45 字数 301 浏览 6 评论 0原文

我有一个 ASP.Net 2.0 站点,想将其转换为 MVC 范例(我对此很陌生),但从零开始。

我的旧网站中有一些主题,但是到处阅读,似乎主题不太适合 MVC 范例。

问题是:

在 MVC 中构建主题用户可定制网站的最佳实践是什么? 如果适用的话,你能举个小例子吗?

注意:我知道这一点,但他们不说话关于最佳实践或如何开始。

I have a ASP.Net 2.0 site and want to translate it into MVC paradigm (I'm new to this), but starting from Zero.

I have some themes in my old site, but reading here and there, it seems like Themes doesn't fit well into MVC paradigm.

The question is:

What is the best practice in MVC for building a Themed user customizable site?
Can you give a little example, if applicable?

Note: I'm aware of this but they don't talk about best practices or how to start with.

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

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

发布评论

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

评论(4

假面具 2024-07-25 02:47:45

这是我在 ASP.NET MVC 中用于实现“主题”的代码:

ASP.NET MVC:使用自定义 ViewEngine 实现主题文件夹

当您能够仅交换 CSS 文件来更改主题时,这很好,但是这在很多情况下确实不太实用。 特别是当每个主题需要有完全不同的布局时。 在这种情况下,您需要更改渲染的 CSS 和 HTML,这就是我编写上述链接中的代码的原因。

Here's my code that I've been using for implementing "Themes" in ASP.NET MVC:

ASP.NET MVC: Implement Theme Folders using a Custom ViewEngine

It's nice when you're able to just swap out CSS files to change the theme, but this really isn't very practical in a ton of cases. Especially when each theme needs to have a completely different layout. In which case, you need to change the CSS and HTML that gets rendered, and this is why I wrote the code found at the above link.

凝望流年 2024-07-25 02:47:45

干净、语义正确的 HTML 加上良好的 CSS 是任何 Web 应用程序主题化的方法,无论是 ASP.NET、RoR、PHP 等。CSS

强大功能的最佳示例是 CSS 禅宗花园

w3schools 有一个很好的CSS 介绍/教程

您的每个用户都可以有一个关联的样式表,只要适用,就会选择该样式表,即:

<link rel="stylesheet" type="text/css" href="<%= Model.SelectedStyleSheet %>"/>

A clean, semantically correct HTML with a good CSS is the way to theme any web app, whether it's ASP.NET, RoR, PHP, etc.

The best example of the power of CSS is CSS Zen Garden.

w3schools has a nice introduction/tutorial to CSS.

Each of your users could have an associated stylesheet which would get selected whenever applicable, i.e.:

<link rel="stylesheet" type="text/css" href="<%= Model.SelectedStyleSheet %>"/>
唐婉 2024-07-25 02:47:45

由于主题旨在设计标签样式,因此您可以使用 CSS 来创建类似的方法。 我可能会建议您首先将默认主题复制到 css 定义,例如

html:

css: input { color : light-blue }

然后对于任何内容有非默认主题的您可以只对它们应用类。 将所有主题重新编写为 CSS 需要一段时间,但一旦完成,一切努力都是值得的。

As themes were intended to style up tags you can use CSS to create a similar approach. I would probably recommend that you start with copying your default themes over to css definitions e.g.

html: <input type="button" />

css: input { color : light-blue }

Then for anything that had your non-default theme you can just apply classes to them. It takes a while to re-write all your themes as CSS, but once done it's worth the effort.

森林散布 2024-07-25 02:47:45

jQuery-ui 主题很好,而且实现起来也不太难。

只需链接到 js 和 css 文件,不要忘记图标。 并确保在这些链接中使用 Url.Content()。 否则,一旦将其部署到生产服务器上,它可能无法链接到正确的路径(我曾经陷入过这个陷阱)。

jQuery-ui themes are nice, and not too hard to implement.

Just link to the js and css file and don't forget the icons. And make sure to use Url.Content() in those links. Otherwise it might not be linked to the correct path, once you deploy it on a production server (i fell into that trap once).

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