473,722 Members | 2,240 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5114
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************ @seventhfloorin c.com> wrote in message
news:Xn******** *************** ***********@207 .46.248.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_P LEASEtkachenko. com> wrote in
news:u9******** ******@TK2MSFTN GP11.phx.gbl:
a little tricky . . . but it worked. Thanks.
Nov 11 '05 #4
Vic,

The System.Web.UI.W ebControls.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.C ontrol.

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.Xpat h;
using System.Xml.Xsl;

public class MyXmlTransforme r : System.Web.UI.C ontrol
{
protected override void Render(HtmlText Writer writer)
{
XPathDocument theXDoc = new XPathDocument(" myxml.xml");

XslTransform theXslt = new XslTransform();
theXslt.Load("t hexslt.xsl");

theXslt.Transfo rm(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************ @seventhfloorin c.com>
Newsgroups:
microsoft.publi c.dotnet.genera l,microsoft.pub lic.dotnet.fram ework.aspnet,mi c
rosoft.public.d otnet.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************ @seventhfloorin c.com> wrote in message
news:Xn******** *************** ***********@207 .46.248.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_P LEASEtkachenko. com> wrote in
news:u9******** ******@TK2MSFTN GP11.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.GetT ype().ToString( )
+ "<br>"
Else
Me.Label1.Text += "Control.ID = " + objControl.ID.T oString +
"<br>"
End If
If objControl.HasC ontrols Then
Me.Label1.Text += "this control has children<br>"
Dim objChild As Control
For Each objChild In objControl.Cont rols
Me.DrillDown(ob jChild)
Next
End If
End Sub

In my XSLT, I'm doing this:

<xsl:for-each select="Survey/Questions/Question">
<p><xsl:value-of select="Questio nText">
</xsl:value-of>
<xsl:choose>
<xsl:when test="@type = 'inputbox'">
<input>
<xsl:attribut e name="type">tex t
</xsl:attribute>
<xsl:attribut e name="id">txtQ
<xsl:value-of select="@id"></xsl:value-of></xsl:attribute>
<xsl:attribut e name="name">txt Q
<xsl:value-of select="@id"></xsl:value-of></xsl:attribute>
<xsl:attribut e 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
1336
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 behaviors). Can anyone clarify: - if Python correctly supports multiple sub-interpreters (Py_NewInterpreter) ?
5
611
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 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,...
1
1302
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 clicks a button on the first form. The project is in C# and ASPX. James Lattanzio
0
916
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" content="JavaScript"> <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
3
4091
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 client. This control now also uses a html file (which gets used as a "dialog" during runtime) and I would like to embed this html file as an assembly resource (just like the above images and scripts) to help make deploying my control's...
1
1344
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 and http://docs.python.org/ext/ext.html. Now I want to wrap classes and functions from the associated libraries so that I can write new applications completely in Python, but I'm not entirely sure how to start because I have some problems...
3
2273
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 a webcontrol library. thanx in advance. its urgent. Neel.
0
8739
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9238
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9088
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6681
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5995
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4762
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3207
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2602
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.