O
Owen Blacker
An awkward question.
In a CMS-like environment, I have a list of items that is generated on
the serverside using an XmlDocument to throw together XHTML tags
(mainly because it's substantially easier than using a Repeater, but
the why is a moot point as the project doesn't have the budget for me
to change that).
Now I have a requirement to add a new list item at the end of each list
that is an "Add new item" form. It's very easy for me to write a
UserControl to handle this form action, but would be relatively
difficult to write this form bit as XmlElements to add into the
existing XmlNode tree.
Is there a way for me to get the output of the server control as an
XmlNode and squish that into my XmlNode tree?
Effectively, I want to take my existing code and making it look
something like this:
bool isInAuthoringMode;
XmlDocument xml;
XmlElement div;
5 // ...
if (isInAuthoringMode || (this.Assets != null &&
this.Assets.Count > 0)
{
10 XmlElement ul = xml.CreateElement("ul");
ul.Attributes.Append(xml.CreateAttribute("class"));
ul.Attributes["class"].Value = "file-list";
foreach (Asset a in this.Assets)
15 ul.AppendChild(a.ToXml(xml));
if (isInAuthoringMode)
ul.AppendChild(new EditControl().ToXml(xml));
20 div.AppendChild(ul);
}
Line 18 in this code block is what I'd really like to be able to do,
but I know that would be being very optimistic.
Is there any obvious way of getting "the HTML this control would
generate here" out of it, even if I have to write a new method into it
somewhere?
The behavior I seek is roughly the same as if I had a Repeater like
this:
<asp:Repeater ...>
<ItemTemplate>
<!-- here would be the output of Asset.ToXml -->
</ItemTemplate>
<FooterTemplate>
<My:EditControl .../>
</FooterTemplate>
</asp:Repeater>
But I can't use a Repeater (for reasons too tedious to detail here).
Any ideas gratefully received. If you could cc: me on any replies,
that'd be very cool, as I only get the digest version of this list.
And apologies to anyone who already read this on any of the LiveJournal
communities I just asked too ;o)
Thanks!
Owen
In a CMS-like environment, I have a list of items that is generated on
the serverside using an XmlDocument to throw together XHTML tags
(mainly because it's substantially easier than using a Repeater, but
the why is a moot point as the project doesn't have the budget for me
to change that).
Now I have a requirement to add a new list item at the end of each list
that is an "Add new item" form. It's very easy for me to write a
UserControl to handle this form action, but would be relatively
difficult to write this form bit as XmlElements to add into the
existing XmlNode tree.
Is there a way for me to get the output of the server control as an
XmlNode and squish that into my XmlNode tree?
Effectively, I want to take my existing code and making it look
something like this:
bool isInAuthoringMode;
XmlDocument xml;
XmlElement div;
5 // ...
if (isInAuthoringMode || (this.Assets != null &&
this.Assets.Count > 0)
{
10 XmlElement ul = xml.CreateElement("ul");
ul.Attributes.Append(xml.CreateAttribute("class"));
ul.Attributes["class"].Value = "file-list";
foreach (Asset a in this.Assets)
15 ul.AppendChild(a.ToXml(xml));
if (isInAuthoringMode)
ul.AppendChild(new EditControl().ToXml(xml));
20 div.AppendChild(ul);
}
Line 18 in this code block is what I'd really like to be able to do,
but I know that would be being very optimistic.
Is there any obvious way of getting "the HTML this control would
generate here" out of it, even if I have to write a new method into it
somewhere?
The behavior I seek is roughly the same as if I had a Repeater like
this:
<asp:Repeater ...>
<ItemTemplate>
<!-- here would be the output of Asset.ToXml -->
</ItemTemplate>
<FooterTemplate>
<My:EditControl .../>
</FooterTemplate>
</asp:Repeater>
But I can't use a Repeater (for reasons too tedious to detail here).
Any ideas gratefully received. If you could cc: me on any replies,
that'd be very cool, as I only get the digest version of this list.
And apologies to anyone who already read this on any of the LiveJournal
communities I just asked too ;o)
Thanks!
Owen