XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Aiman AshrafSubject: ASP.NET XSL custom control
Author: Aiman Ashraf
Date: 14 Sep 2005 03:45 PM
Hi to all,

It's possible to throw ASP.NET controls on to a page using XSL but is it possible to throw a .NET custom control on to a page using XSL?

This is the error I get:
Unknown server tag sec:MyCheckBox

Any help would be really appreciated

Thanks,
supernewbie

Postnext
Ivan PedruzziSubject: ASP.NET XSL custom control
Author: Ivan Pedruzzi
Date: 15 Sep 2005 03:59 PM
Could you post the code fragment?

Ivan Pedruzzi
Stylus Studio Team

Postnext
Aiman AshrafSubject: ASP.NET XSL custom control
Author: Aiman Ashraf
Date: 15 Sep 2005 04:33 PM
This is the code (VB). The error is thrown at oCtl = Page.ParseControl(strOutput). The error is Unknown server tag 'sec:CheckBox'

Try
Dim xslTransform As New Xsl.XslTransform
Dim sw As New System.IO.StringWriter
Dim oCtl As Control
Dim xmlDocMain As New System.Xml.XmlDocument

xmlDocMain.Load("C:\VSSWorking\Source\EQWebApplication\MemosXMLXSL\Memos.xml")
Dim navigator As XPath.XPathNavigator = xmlDocMain.CreateNavigator()

navigator = xmlDocMain.CreateNavigator()
xslTransform.Load("C:\VSSWorking\Source\EQWebApplication\MemosXMLXSL\OICDeclined.xsl")
xslTransform.Transform(navigator, Nothing, sw, Nothing)

strOutput = sw.ToString
'remove the dummy namespace attribute
If Not strOutput = "" Then
' strOutput = strOutput.Replace("xmlns:asp=""remove""", "")
strOutput = strOutput.Replace("xmlns:sec=""remove""", "")
End If
oCtl = Page.ParseControl(strOutput)
phdExtraInfo.Controls.Clear()
phdExtraInfo.Controls.Add(oCtl)
Finally
End Try

And the xsl looks like:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sec="remove">
<xsl:template match="/">

<TABLE id="ExtraInfoTable" style="Z-INDEX: 103; LEFT: 1px; WIDTH: 100%; POSITION: relative; TOP: 1px; HEIGHT: 1px" cellSpacing="0" cellPadding="0" border="0">
<xsl:for-each select="Memos/ODN/Security">
<tr>
<TD width="25%"><xsl:value-of select="Name"/></TD>
<td width="75%">
<sec:CheckBox id="{controlID}" style="POSITION: relative" runat="server" Width="128px" Height="32px" Text="SecurityControl"></sec:CheckBox>
</td>
</tr>
</xsl:for-each>
</TABLE>
</xsl:template>
</xsl:stylesheet>

PS: This method works great when throwing asp controls.

Thanks
Aiman Ashraf

Postnext
(Deleted User) Subject: ASP.NET XSL custom control
Author: (Deleted User)
Date: 16 Sep 2005 02:57 AM
Hi Aiman,
why do you remove the xmlns:sec namespace declaration? That operation will make the XML invalid...

Alberto

Posttop
Aiman AshrafSubject: ASP.NET XSL custom control
Author: Aiman Ashraf
Date: 16 Sep 2005 07:28 AM
Hi,

Well, the remove xmlns:sec is done from the output string of the XSL transform method (which is html)...so that's not a problem....

Anyway, I found the solution. Though this is related more to .NET than XSL but anyway here goes:

We just have to prepend the following string to the output of the transform method:
Dim result As String = "<%@ Register TagPrefix=""sec"" Namespace=""MyNamespace"" Assembly=""MyAssembly"" %>"

Basically, this tells the page where to find the tag and the corresponding control.

Regards,
Aiman

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.