Web-MA ASP.Net MWPSK Embed Resource

Current Version: 1.0.0 relesead on 02/02/2008

An extension to let Microsoft My Web Page Starter Kit embed extra resource file (CSS or Javascript)


This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

The GNU license to which this software is referering is available at: http://www.gnu.org/licenses/gpl.txt

If you want, you can add a link to www.web-ma.com, making it easy for others to recognize the author of this script.


Why this extension?

Finding an open source CMS (hence free) written in C# 2.0, which does not need a database to store data is not easy. On ASP.Net platform, there aren't so much solutions like per Linux platform, and Microsoft guy did a great job when they released the MWPSK.
But like for everything, also in this case something was missing, and so once again here it's my solution based on the work MWPSK team did and stored on CodePlex.

Why use this extension?

To be honest in this case the probles is not something missing in the logic of MWPSK, but the way how themes are managed in ASP.Net that I don't like it at all.
The themes logic strictly embed all files contained in a certain root path below the App_Themes folder. And this embedding operation is done for all files contained in the path - independently of the extension - and for every page that use that theme.
All the files will be used in different manner according to the extension, so for a moment imagine that in that path there are just .css files (Cascade Style Sheet).

Before continue, let me explain how the CSS work. Well you could know how it does, but it's better spend some words here also to understand why I decided to implement this new section.

Standard logic of CSS file says that you can "stylize" HTML tag in different way. Accessing element by ID, style in this case is just for a specific control, by class, so many controls can benefit by specific style rules.
About name collision, CSS doesn't worry about name clash. This mean that you can declare a class or a control id many times in your style sheet file. In all case the rule that take part is always the last one read.
Transporting this argument to the above ASP.Net scenario, since all CSS file will be included in the reference of each web page, this mean that you couldn't have a main page or a secondary page viewing them by theme side until you wouldn't differentiate and access to secondary (or primary) page tags just for ID and give attention to use a different HTML ID attribute for each single control.
Synthesizing, this mean that a very complex HTML layout that need to make this difference will result in a very complex CSS design that often mean repeat tons of CSS code (that obviously will be downloaded on the client side too downgrading - in some case - also the performance).

Not a nice scenario, huh?

If you agree with me, here there is the solution for Microsoft My Web Page Starter Kit.

Initially I designed this section just for CSS files, but going over with development, I extended it to javascript files too. So actually the section is able to manage both CSS and Javascript files stored under current theme path of your running CMS.
The section simply read a list of the files that are in the folder, propose them in a list from which you can choose one. Finally press the save button to embed the resource. (To embed more than one resource, simply add more than one section).

Just to make another example: imagine a crypto jascript routine used to mask e-mail address in the contact page. Do you need it in all page or just in one?
Obviously for .js files, if they are callable routine, you have to make an html call too, but this can be done using standard HTML control provided with MWPSK, but this is outside the scope of this instruction page.

How to use this module?

To implement this module, differently for the SEO Extension, you don't know how to program in ASP.Net.
What you have to do is just copy some files into the appropriate folder, append a bunch of lines into the resource file, and open http location of your MWPSK personal copy. That's all.

Have a look together how to paste the files contained in the zip downloadable at the end of the page (Please note that a txt file wihtin the current instruction is provided also into the zip file).

  1. Copy the EmbedResource.ascx and EmbedResource.ascx.cs into the ~/SectionControls;
  2. Copy the EmbedResource.cs file into the ~/App_Code/Sections;
  3. Append the content of the StringRes.resx.txt file to the StringRes.resx file in the ~/App_GlobalResources and eventually to any other file you need to localize;
  4. Enjoy the EmbedResource section.

Download

For your best convenience I've provided a zip file with the MWPSK Embed Resource developed on the 1.1.4 version.

Back to Open Source Utility list.



Copyright © 2008 http://www.web-ma.com. All rights reserved.