c# - How to display xml string in a Label? -
i trying html method below, encode string , display on label, keep getting blank page, on client-side.
i have checked viewsource , shows no html output also.
public partial class : page { protected void page_load(object sender, eventargs e, string data) { if (!ispostback) { string = createxmlpub(data); // label1.text = httputility.htmlencode(a); label1.text = server.htmlencode(a); } } public static string createxmlpub(string data ) { xelement xeroot = new xelement("pub"); xelement xename = new xelement("name", "###"); xeroot.add(xename); xelement xecategory = new xelement("category", "#####"); xeroot.add(xecategory); xdocument xdoc = new xdocument(xeroot); data = xdoc.tostring(); return data; }
html
<asp:content runat="server" id="bodycontent" contentplaceholderid="maincontent"> <asp:label id="label1" runat="server" text="label"></asp:label> </asp:content>
please advice, may going wrong code. many thanks
- your
page_load
isn't fired - re:string data
param doesn't match signature event delegate
so:
protected void page_load(object sender, eventargs e) { if (!ispostback) { string = createxmlpub(); label1.text = server.htmlencode(a); } } public static string createxmlpub() { xelement xeroot = new xelement("pub"); xelement xename = new xelement("name", "###"); xeroot.add(xename); xelement xecategory = new xelement("category", "#####"); xeroot.add(xecategory); xdocument xdoc = new xdocument(xeroot); return xdoc.tostring(); }
hth...
Comments
Post a Comment