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?