简体   繁体   English

如何将可自定义的外观应用于ASP.NET网站?

[英]How to apply customizable skins to an ASP.NET web site?

I'm writing a SaaS application with a web front end written in ASP.NET. 我正在编写一个用ASP.NET编写的Web前端的SaaS应用程序。 I'm not much of a designer, and my ASP.NET knowledge is not yet at the expert level - I usually focus on server side stuff - but I have a basic master page and style sheets, which do the trick. 我不是设计师,我的ASP.NET知识还不是专家级(我通常专注于服务器端内容),但是我有一个基本的母版页和样式表,可以解决问题。

Now I want to offer my customers the ability to customize their web site with their own style sheets, colors, background pictures etc. so that their customers will log onto their portal at mycustomer.mydomain.com and see the skin that "mycustomer" has chosen. 现在,我想为客户提供使用自己的样式表,颜色,背景图片等自定义其网站的功能,以便他们的客户登录到mycustomer.mydomain.com上的门户并查看“ mycustomer”拥有的皮肤选择。

Haven't the faintest clue how to do this. 没有最微妙的线索如何做到这一点。 How? 怎么样?

If you are allowing the customer to specify his own CSS (either as a File or in some textBox in your Page). 如果允许客户指定自己的CSS(作为File或在Page的某些textBox中)。 You can simply save it as a .css file in a virtual directory and During Page_Load or Page_Init Event add it to your page. 您可以简单地将其另存为.css文件在虚拟目录中,然后在Page_LoadPage_Init事件期间将其添加到页面中。 You need to push a Link tag to Header of the page 您需要将链接标记推送到页面的标题

Like this: 像这样:

// Define an HtmlLink control.
HtmlLink myHtmlLink = new HtmlLink();
myHtmlLink.Href = "~/CustomersCustomStyleSheet.css";
myHtmlLink.Attributes.Add("rel", "stylesheet");
myHtmlLink.Attributes.Add("type", "text/css");

// Add the HtmlLink to the Head section of the page.
Page.Header.Controls.Add(myHtmlLink);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM