基于服务器控件动态加载样式表
我有一个网站,需要根据模型加载基本样式组件(根据用户输入在后端 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
样式表无法从数据库中提取,但您当然可以创建一个处理程序来提供 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.