I am using an XElement object to generate some HTML in the code on an ASP.NET page.
I can or cannot add some XAttributes to this XElement when I go, as follows:
var elmnt = new XElement("div",
new XAttribute("id", "myDiv"),
);
Now, if I want to add some content to myDiv that contains HTML, XElement automatically eludes this, which is undesirable in my situation.
So, if I have:
var elmnt = new XElement("div",
new XAttribute("id", "myDiv"),
"<span id='content'>hello world</span>"
);
And then I pass it to the Placeholder object using the following code:
myPlaceholder.Controls.Add(new System.Web.UI.WebControls.Literal { Text = elmnt.CreateNavigator().OuterXml });
When the page loads, the source indicates that the internal content inside elmnt has been escaped and has the following format in the page source:
<span id='content'>hello world</span>
, XML, , HTML, HTML, XElement, ? ?