Download Advertiser - 44.3 KB
lately I've been playing with xml/xslt transformation and just noticed how easy I can produce whatever contents from plain xml files, overriding my traditional time-consuming technique of parsing xml, I decided to play a lettle pit with my Advertiser module, which can be of use on websites when you want to host people's advertises. this module should do it without database at all.
Using the code
First here's the structure of the sample website:
|--->Admin [Amin area]
| |--->Add.aspx [add files to locations]
| |--->Default.aspx [display/edit/delete files]
| |--->Edit.aspx [edit files]
| |--->flashfix.js [used to render flash]
| |--->Advertiser.ascx [user control displays the transformed file]
|---->UploadedData [+r/+w permission required]
| |--->config [Configuraion files]
| | |
| | |--->Advertiser.xml
| | |--->Advertiser.xslt
| |----> [Ad. files]
|---->Default.aspx [Test page]
The Xml file looks like this :
<table cellpadding="0" cellspacing="0" border="0" id="tbl">
<xsl:when test="contains(type, $AdvType)">
<xsl:if test="string-length(normalize-space(url)) > 0">
<xsl:value-of select="url" />
<xsl:value-of select="path" />
<xsl:value-of select="width" />
<xsl:value-of select="height" />
RenderFlash('<xsl:value-of select="path" />', <xsl:value-of select="width" />, <xsl:value-of select="height" />);
The display page is based on a user control "Advertiser.ascx" with a property "Location" which tells the control to fetch the advertises in that belongs to this specefic location.
private Advertiser.Location _Location;
While in the Admin area I decided to play dirty parsing the xml manually, to show the difference beteen the xslt style and the hard code one, although during the developement I was confronted by this annoying delima, how can I use xslt to fetch specefic location's ads and displaying them separetly in a datagrid along with eidt and delete controls.
In the user control there was no problem retrieving the ads of a location and render them directely on the control area, but I didn't manage to go arround that to feed them to a datagrid at the moment.
Points of Interest
It is quite interesting in fact how xslt simplifies the work with xml data, that is the core of this project
Keep a running update of any changes or improvements you've made here.