I'm trying to add a list of banners to my template.
For it I created two document types: one for list itself and another for single banner. I added property for advertisement xml file into banner document type. This xml I placed in media.
the asp.net AdRotator is a server control. You can't use these controls in xslt. What you can do is create a usercontrol and use that as the macro. On the usercontrol you can put the AdRotator.And i think (not sure) you can use it in a Razor Macro also.
Using asp:AdRotator in XSLT
I'm trying to add a list of banners to my template.
For it I created two document types: one for list itself and another for single banner. I added property for advertisement xml file into banner document type. This xml I placed in media.
In my template I need to get following:
<table>
<tr><td> <asp:AdRotator runat="server" Target="_blank" AdvertisementFile="~/media/502/adds.xml"/>
<tr> <td> <asp:AdRotator runat="server" Target="_self" AdvertisementFile="~/media/502/adds.xml"/>
<tr> <td> <asp:AdRotator runat="server" Target="_self" AdvertisementFile="~/media/502/adds.xml"/>
</table>
I try to do the following:
1. In my template I added
<umbraco:macro alias="umbBunnersListItems" runat="server"></umbraco:macro>
2. My macro uses xslt. I tried to write like this
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp " ">
]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:tagsLib="urn:tagsLib" xmlns:BlogLibrary="urn:BlogLibrary"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets tagsLib BlogLibrary "
>
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:template match="/">
<table>
<xsl:for-each select="umbraco.library:GetXmlNodeById(1164)/Bunner">
<tr><td>
<xsl:element name="asp:AdRotator">
<xsl:attribute name="runat">server</xsl:attribute>
<xsl:attribute name="Target">_blank</xsl:attribute>
<xsl:attribute name="AdvertisementFile">
<xsl:value-of select="./pathToXml"/>
</xsl:attribute>
</xsl:element>
</td></tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
but I get an error:
System.Xml.Xsl.XslLoadException: "asp" .(Prefix "asp" not found)
C:\inetpub\wwwroot\energotrade.ru\xslt\634364794739606274_temp.xslt(19,9).
System.Xml.Xsl.XslCompiledTransform.LoadInternal(Object stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)
System.Xml.Xsl.XslCompiledTransform.Load(XmlReader stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)
umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging) C:\Users\Administrator\Desktop\\Sources-binaries\Umbraco\umbraco 4.5\umbraco\presentation\umbraco\webservices\codeEditorSave.asmx.cs: 127
Then I tried to add xmlns:asp="asp" in <xsl:element name="asp:AdRotator">, but this didn't help.
Is there any way rto solve this problem? Or may be you can advise me another way to add banners dinamically to my template.
Hi Anna,
the asp.net AdRotator is a server control. You can't use these controls in xslt. What you can do is create a usercontrol and use that as the macro. On the usercontrol you can put the AdRotator.And i think (not sure) you can use it in a Razor Macro also.
Cheers,
Richard
I created UserControl with AdvertisementFile public property - macro parameter.
<umbraco:Macro AdvertisementFile="~/media/502/adds.xml" Alias="AddRotatorControl" runat="server"></umbraco:Macro>
But I need AdvertisementFile to be set to property of object in my Content.
is working on a reply...