473,382 Members | 1,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Embedding XML into ASPX question

I have an XML string in a database that I would like to display using XSLT.
All of that works like a champ, but I can't figure out how to embed the XML
inside an ASPX page.

For example, I have an ASPX page with a Header User Control and a Footer
User Control. I'd like to put the transformed XML right in the middle. It
seems like this is something that should be doable, but I can't quite
figure it out. Is anyone out there doing this, and if so, can you point me
in the right direction?

Thanks,
Vic Fees
Nov 11 '05 #1
5 5084
Put a PlaceHolder or LiteralControl where you want the XML to be, and add it
to that control.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Complex things are made up of
lots of simple things.

"Victor Fees" <vf************@seventhfloorinc.com> wrote in message
news:Xn**********************************@207.46.2 48.16...
I have an XML string in a database that I would like to display using XSLT. All of that works like a champ, but I can't figure out how to embed the XML inside an ASPX page.

For example, I have an ASPX page with a Header User Control and a Footer
User Control. I'd like to put the transformed XML right in the middle. It seems like this is something that should be doable, but I can't quite
figure it out. Is anyone out there doing this, and if so, can you point me in the right direction?

Thanks,
Vic Fees

Nov 11 '05 #2
Victor Fees wrote:
I have an XML string in a database that I would like to display using XSLT.
All of that works like a champ, but I can't figure out how to embed the XML
inside an ASPX page.

For example, I have an ASPX page with a Header User Control and a Footer
User Control. I'd like to put the transformed XML right in the middle.

You can put placeholder <div> between them and fill transformation result to
its InnerHtml property.
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #3
Oleg Tkachenko <oleg@NO_SPAM_PLEASEtkachenko.com> wrote in
news:u9**************@TK2MSFTNGP11.phx.gbl:
a little tricky . . . but it worked. Thanks.
Nov 11 '05 #4
Vic,

The System.Web.UI.WebControls.Xml class is designed for exactly this
functionality.
It has 2 pulic properties: Document and Transform which take your Xml
Document and Xslt Transform Document respectively and
perform the transform for you. Like any WebControl it can just be dropped
on your aspx page.

Another way to do it, and the way I do it for performance reasons, is to
write your own Custom Control derived from System.Web.UI.Control.

This gives you an HtmlTextWriter that you can write to by performing an Xsl
Transform on an XPath Document, the XPath document is more
performant than the Xml Document class. Try something like the following:

using System;
using System.Web;
using System.Web.UI;
using System.Xml;
using System.Xml.Xpath;
using System.Xml.Xsl;

public class MyXmlTransformer : System.Web.UI.Control
{
protected override void Render(HtmlTextWriter writer)
{
XPathDocument theXDoc = new XPathDocument("myxml.xml");

XslTransform theXslt = new XslTransform();
theXslt.Load("thexslt.xsl");

theXslt.Transform(theXDoc, null, writer);
}
}

Then just drop one of these on your aspx page. Obviously the above can be
made more re-usable by exposing the
XPathDocument and XslTransform as properties of the class, mess about with
it and see what you come up with.

Hope this helps,

Dave
----- Original Message -----
From: "Victor Fees" <vf************@seventhfloorinc.com>
Newsgroups:
microsoft.public.dotnet.general,microsoft.public.d otnet.framework.aspnet,mic
rosoft.public.dotnet.xml
Sent: Wednesday, July 30, 2003 2:44 PM
Subject: Embedding XML into ASPX question

I have an XML string in a database that I would like to display using XSLT. All of that works like a champ, but I can't figure out how to embed the XML inside an ASPX page.

For example, I have an ASPX page with a Header User Control and a Footer
User Control. I'd like to put the transformed XML right in the middle. It seems like this is something that should be doable, but I can't quite
figure it out. Is anyone out there doing this, and if so, can you point me in the right direction?

Thanks,
Vic Fees "Victor Fees" <vf************@seventhfloorinc.com> wrote in message
news:Xn**********************************@207.46.2 48.16... I have an XML string in a database that I would like to display using XSLT. All of that works like a champ, but I can't figure out how to embed the XML inside an ASPX page.

For example, I have an ASPX page with a Header User Control and a Footer
User Control. I'd like to put the transformed XML right in the middle. It seems like this is something that should be doable, but I can't quite
figure it out. Is anyone out there doing this, and if so, can you point me in the right direction?

Thanks,
Vic Fees

Nov 11 '05 #5
Oleg Tkachenko <oleg@NO_SPAM_PLEASEtkachenko.com> wrote in
news:u9**************@TK2MSFTNGP11.phx.gbl:
Victor Fees wrote:
I have an XML string in a database that I would like to display using
XSLT. All of that works like a champ, but I can't figure out how to
embed the XML inside an ASPX page.

For example, I have an ASPX page with a Header User Control and a
Footer User Control. I'd like to put the transformed XML right in
the middle.

You can put placeholder <div> between them and fill transformation
result to its InnerHtml property.


I have a follow-up question about this . . . . I have HTML generic
textboxes in my XSLT, and would like to reference them in the code-behind
for the page in which I am embedding the XML. I've used a recursive
subroutine to prove that I can see the control in the code-behind, but I
can't seem to access anything of value (i.e., ID).

Private Sub DrillDown(ByVal objControl As Control)
If objControl.ID Is Nothing Then
Me.Label1.Text += "Type: " + objControl.GetType().ToString()
+ "<br>"
Else
Me.Label1.Text += "Control.ID = " + objControl.ID.ToString +
"<br>"
End If
If objControl.HasControls Then
Me.Label1.Text += "this control has children<br>"
Dim objChild As Control
For Each objChild In objControl.Controls
Me.DrillDown(objChild)
Next
End If
End Sub

In my XSLT, I'm doing this:

<xsl:for-each select="Survey/Questions/Question">
<p><xsl:value-of select="QuestionText">
</xsl:value-of>
<xsl:choose>
<xsl:when test="@type = 'inputbox'">
<input>
<xsl:attribute name="type">text
</xsl:attribute>
<xsl:attribute name="id">txtQ
<xsl:value-of select="@id"></xsl:value-of></xsl:attribute>
<xsl:attribute name="name">txtQ
<xsl:value-of select="@id"></xsl:value-of></xsl:attribute>
<xsl:attribute name="runat">
server</xsl:attribute>
</input>
</xsl:when>
</xsl:choose>
<xsl:value-of select="@id"></xsl:value-of>
</p>
</xsl:for-each>

So, you can see that the "inputbox" is a generic html <input> with an id
of txtQ1 and a name of txtQ1. However, I can't find a variable that
gives me this value in the code behind. I've tried using <asp:TextBox>
embedded in my XML, but that provides a new set of problems -- the ID
turns out to be TextBox1, and the display gets worse.

Regardless, any idea what I'm doing wrong here?
Nov 11 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: adsheehan | last post by:
Hi, I am embedding Python into a multi-threaded C++ application runnig on Solaris and need urgent clarification on the embedding architecture and its correct usage (as I am experience weird...
5
by: Victor Fees | last post by:
I have an XML string in a database that I would like to display using XSLT. All of that works like a champ, but I can't figure out how to embed the XML inside an ASPX page. For example, I have...
1
by: James Lattanzio | last post by:
Dear Anyone, If this is not the appropriate place to as an ASPX question, please point to the correct location. If it is the right place then, how can I open a second web form after the user...
0
by: EMW | last post by:
Hi, I use the following to start my ASPX: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>index</title> <meta name="vs_defaultClientScript"...
3
by: Praveen | last post by:
Hi, I have a control that currently embeds it's images and script files as resources (by marking them as 2.0's WebResourceAttribute) and lets the runtime handle the streaming of the files to the...
1
by: Thomas Troeger | last post by:
Dear all, I've successfully embedded the Python interpreter into a set of C/C++ application programs that use a larger library project with information from http://docs.python.org/api/api.html...
3
by: sweetneel | last post by:
hI all , i have developed a webcontrol library for a custom data grid. now i want to embed a aspx page for the Searching database .in to this dll. now how should i embed a aspx page with controls in...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.