基于服务器控件动态加载样式表

发布于 2024-11-03 13:56:48 字数 209 浏览 4 评论 0原文

我有一个网站,需要根据模型加载基本样式组件(根据用户输入在后端 SQL 服务器上确定)。

这个概念是该网站可以包含基于登陆页面预定义的参数化外观组件。

任何人都可以提供如何实现这一目标的基本想法或示例吗?一个想法是将样式参数存储在数据库中,但是样式表如何实现这一点。另一个想法是让这些预定义的样式表与着陆页相对应,但这需要服务器控件,并且我们无法在链接样式表中实现此功能。

I have a website that will need to load basic style components based on the model (determined on backend SQL server based on user input)

The concept is that this website can contained parameterized look-and-feel components which are predefined based on a landing page.

Can any one provide a basic idea or example of how to accomplish this? One idea was to store style parameters at the database, but how could a style sheet pull this. Another idea is to have these predefined style sheets corresponding to the landpage, but this would require a server control, and we wouldn't be able to implement this in the to link the style sheet.

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

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

发布评论

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

评论(1

奶茶白久 2024-11-10 13:56:48

样式表无法从数据库中提取,但您当然可以创建一个处理程序来提供 CSS 文件而不是指向物理 CSS 文件。

然而,这里更大的问题更多的是业务问题。在编码之前,您必须弄清楚控件或布局到 CSS 文件的映射。如果你不这样做,我几乎可以保证,当你的系统无法满足要求时,你将会经历一些痛苦。如果您不想承受太多痛苦,请预先做好设计工作。

现在,回到问题上来。 “基于登陆页面”?您的意思是不同的用户点击不同的登陆页面。如果是这样,样式可以应用于模板(在 ASP.NET 中很容易),或者您可以创建自定义配置文件提供程序以将样式与用户结合起来。我会仔细考虑这些选择。将文件存储为文件或数据库中是一个单独的问题。

Style sheets cannot pull from a database, but you certainly can make a handler that serves up the CSS file rather than point to a physical CSS file.

The bigger problem here, however, is more of a business problem. You have to figure out the mapping of controls or layouts to CSS files prior to coding this. If you don't I can almost guarantee you are going to experience some pain down the road when you system cannot handle the requirements. Do the design work up front if you don't want too much pain.

Now, back to the issue. "Based on a landing page"? Do you mean different users hit different landing pages. If so, the styling can be applied to templates (easy in ASP.NET) or you can create a custom profile provider to marry style to user. I would think through those options. The storage of the file as a file or in the database is a separate issue.

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