<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>CTRLALT313373.com - ASP.NET</title>
    <link>http://weblog.ctrlalt313373.com/</link>
    <description>.Net Wanderings</description>
    <language>en-us</language>
    <copyright>David A. Osborn</copyright>
    <lastBuildDate>Mon, 29 Oct 2007 01:03:34 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.9074.18820</generator>
    <managingEditor>davido@ctrlalt313373.com</managingEditor>
    <webMaster>davido@ctrlalt313373.com</webMaster>
    <item>
      <trackback:ping>http://weblog.ctrlalt313373.com/Trackback.aspx?guid=f8f23d92-b43f-4050-b275-0ea3ff7fbd2b</trackback:ping>
      <pingback:server>http://weblog.ctrlalt313373.com/pingback.aspx</pingback:server>
      <pingback:target>http://weblog.ctrlalt313373.com/PermaLink,guid,f8f23d92-b43f-4050-b275-0ea3ff7fbd2b.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://weblog.ctrlalt313373.com/CommentView,guid,f8f23d92-b43f-4050-b275-0ea3ff7fbd2b.aspx</wfw:comment>
      <wfw:commentRss>http://weblog.ctrlalt313373.com/SyndicationService.asmx/GetEntryCommentsRss?guid=f8f23d92-b43f-4050-b275-0ea3ff7fbd2b</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I originally thought of this idea while at Professional Edge. We had a client that
wanted to build a portal and resell the functionality it provided to other companies.
The main functionality and content for the site would be the same for each customer,
but styles, images, and logos would change based on each company allowing the company
to portray the website as their own. Professional Edge closed before the project was
signed off on so I never got the chance to tackle a solution, but every once in awhile
the concepts pops back into my head. I am sure this is a fairly common scenario and
most likely what I have done here has been done plenty of times before, but I thought
I would attempt to put together a proof of concept. My initial plan was to dynamically
generate the App_Themes data based on information from the database. Using this method
the developer would build the site with the look and feel defined via css tags and
skin ids. The end corporate user would then have a user interface to define their
custom styles and images that applied to each css tag and skin id. If the user did
not define a tag then the website would simple use a default theme that the developer
defined. 
</p>
        <p>
To do all this I have utilized the functionality of virtual path providers. A virtual
path provider allows you to essentially take over when ASP.NET is looking for the
file to server to the user. In my particular case it is for .css and .skin files,
so that whenever a request comes in for one of these files it is instead dynamically
built based on data from the database. Originally I had planned to associate a particular
theme name with each portal's customizations. For example on the pre-init the theme
would be dynamically set based on some type of user information, either a login account,
or possibly the web address used to access the site. Basically any type of information
that establishes the unique portal that the visitor is attempting to reach. Unfortunately
this plan won't work. Apparently ASP.NET requires the actual physical files for a
theme to exist or else it will throw an error. This was a bit of a disappointment
to me as I had hoped to parse the theme name in the virtual path provider to know
what dynamic data to load. Since the path is the only data passed into the virtual
path provider it is the easiest and cleanest way to know what data to load. If the
file trying to be loaded is ThemeABC.css I could load the styles for portal ABC and
if the file trying to be loaded was ThemeXYZ.css then I could have loaded the styles
for portal XYZ. 
</p>
        <p>
Even though this method didn't work I was able to development another method that
does. I have created the file structure for the Default theme with dummy files, including
Default.css and Default.skin. Every portal will essentially be using this theme as
far as ASP.NET is concerned, but when a request comes in for Default.css or Default.skin
I pass back a dynamically generated file. The decision for what styles and ids need
to be loaded is based on a cookie that is set in the pre-init. This cookie is then
read in the in the Open function of the virtual file class for the virtual path provider
and based on what the cookie says a decision is made as to what styles are handed
back to the client. 
</p>
        <p>
In the attached sample code there are two different themes that can be accessed, blue
and red. Setting the cookie is handled in the Default.aspx's OnPreInit. Since this
is a proof of concept the actually string is hard coded, but it could just as easily
read the address that the request came in on, a user login, or user setting. Then
in the virtual path provider I handle any of the requests that come in for APP_THEME/DEFAULT/.
Finally in the virtual file class I read the theme name from the cookie and hand back
the proper page. Since this is a proof of concept I have simply hardcoded a few values
to hand back, but you could easily query the database and hand back a much more dynamically
generated file. 
</p>
        <p>
At this point hopefully you can see the numerous possibilities this allows for. If
all the ok buttons on the entire site are defined with a skin id of btnOk then you
could allow the user to upload the image they want for their ok buttons and instantly
all the ok buttons on the site reflect what the user has defined. If you consistently
use your css tags within you site then the user could easily define custom colors,
fonts, etc. for each one. This would allow the user to very easily customize the site
to the look and feel that represents their company without having a developer make
any changes. 
</p>
        <p>
Feel free to check out the sample code at the link below and make any comments or
suggestions. Since it is just a proof of concept it is a little rough and not that
elegant, but it displays the point. 
</p>
        <p>
          <a href="http://www.ctrlalt313373.com/LinkClick.aspx?fileticket=%2flXjUSp%2f%2bCI%3d&amp;tabid=65&amp;mid=390">Download
the source code to the proof of concept. (VS2008 required)</a>
        </p>
        <p>
        </p>
        <p>
        </p>
        <img width="0" height="0" src="http://weblog.ctrlalt313373.com/aggbug.ashx?id=f8f23d92-b43f-4050-b275-0ea3ff7fbd2b" />
      </body>
      <title>Dynamically Generating CSS and Skin Files for Custom User Experience</title>
      <guid isPermaLink="false">http://weblog.ctrlalt313373.com/PermaLink,guid,f8f23d92-b43f-4050-b275-0ea3ff7fbd2b.aspx</guid>
      <link>http://weblog.ctrlalt313373.com/2007/10/29/DynamicallyGeneratingCSSAndSkinFilesForCustomUserExperience.aspx</link>
      <pubDate>Mon, 29 Oct 2007 01:03:34 GMT</pubDate>
      <description>&lt;p&gt;
I originally thought of this idea while at Professional Edge. We had a client that
wanted to build a portal and resell the functionality it provided to other companies.
The main functionality and content for the site would be the same for each customer,
but styles, images, and logos would change based on each company allowing the company
to portray the website as their own. Professional Edge closed before the project was
signed off on so I never got the chance to tackle a solution, but every once in awhile
the concepts pops back into my head. I am sure this is a fairly common scenario and
most likely what I have done here has been done plenty of times before, but I thought
I would attempt to put together a proof of concept. My initial plan was to dynamically
generate the App_Themes data based on information from the database. Using this method
the developer would build the site with the look and feel defined via css tags and
skin ids. The end corporate user would then have a user interface to define their
custom styles and images that applied to each css tag and skin id. If the user did
not define a tag then the website would simple use a default theme that the developer
defined. 
&lt;/p&gt;
&lt;p&gt;
To do all this I have utilized the functionality of virtual path providers. A virtual
path provider allows you to essentially take over when ASP.NET is looking for the
file to server to the user. In my particular case it is for .css and .skin files,
so that whenever a request comes in for one of these files it is instead dynamically
built based on data from the database. Originally I had planned to associate a particular
theme name with each portal's customizations. For example on the pre-init the theme
would be dynamically set based on some type of user information, either a login account,
or possibly the web address used to access the site. Basically any type of information
that establishes the unique portal that the visitor is attempting to reach. Unfortunately
this plan won't work. Apparently ASP.NET requires the actual physical files for a
theme to exist or else it will throw an error. This was a bit of a disappointment
to me as I had hoped to parse the theme name in the virtual path provider to know
what dynamic data to load. Since the path is the only data passed into the virtual
path provider it is the easiest and cleanest way to know what data to load. If the
file trying to be loaded is ThemeABC.css I could load the styles for portal ABC and
if the file trying to be loaded was ThemeXYZ.css then I could have loaded the styles
for portal XYZ. 
&lt;/p&gt;
&lt;p&gt;
Even though this method didn't work I was able to development another method that
does. I have created the file structure for the Default theme with dummy files, including
Default.css and Default.skin. Every portal will essentially be using this theme as
far as ASP.NET is concerned, but when a request comes in for Default.css or Default.skin
I pass back a dynamically generated file. The decision for what styles and ids need
to be loaded is based on a cookie that is set in the pre-init. This cookie is then
read in the in the Open function of the virtual file class for the virtual path provider
and based on what the cookie says a decision is made as to what styles are handed
back to the client. 
&lt;/p&gt;
&lt;p&gt;
In the attached sample code there are two different themes that can be accessed, blue
and red. Setting the cookie is handled in the Default.aspx's OnPreInit. Since this
is a proof of concept the actually string is hard coded, but it could just as easily
read the address that the request came in on, a user login, or user setting. Then
in the virtual path provider I handle any of the requests that come in for APP_THEME/DEFAULT/.
Finally in the virtual file class I read the theme name from the cookie and hand back
the proper page. Since this is a proof of concept I have simply hardcoded a few values
to hand back, but you could easily query the database and hand back a much more dynamically
generated file. 
&lt;/p&gt;
&lt;p&gt;
At this point hopefully you can see the numerous possibilities this allows for. If
all the ok buttons on the entire site are defined with a skin id of btnOk then you
could allow the user to upload the image they want for their ok buttons and instantly
all the ok buttons on the site reflect what the user has defined. If you consistently
use your css tags within you site then the user could easily define custom colors,
fonts, etc. for each one. This would allow the user to very easily customize the site
to the look and feel that represents their company without having a developer make
any changes. 
&lt;/p&gt;
&lt;p&gt;
Feel free to check out the sample code at the link below and make any comments or
suggestions. Since it is just a proof of concept it is a little rough and not that
elegant, but it displays the point. 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.ctrlalt313373.com/LinkClick.aspx?fileticket=%2flXjUSp%2f%2bCI%3d&amp;amp;tabid=65&amp;amp;mid=390"&gt;Download
the source code to the proof of concept. (VS2008 required)&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://weblog.ctrlalt313373.com/aggbug.ashx?id=f8f23d92-b43f-4050-b275-0ea3ff7fbd2b" /&gt;</description>
      <comments>http://weblog.ctrlalt313373.com/CommentView,guid,f8f23d92-b43f-4050-b275-0ea3ff7fbd2b.aspx</comments>
      <category>ASP.NET</category>
      <category>Development</category>
    </item>
  </channel>
</rss>