c# - Returning an HtmlTable to be written with ajax -


I want to create a HtmlTable / table programmatically in the code behind a webservice and return it as a string Wish HTML so that it can be written with javascript in a span / div / whatever

:

  // webservice.amsx.cs Build table, which A secured string from another / different method is called Table_Maker () (HtmlTable tbl = new HtmlTable (); HtmlTableCell cell = new HtmlTableCell (); HtmlTableRow line = new HtmlTableRow (); Cell.InnerT Ext = "whatever text"; row.Cells.Add (cell); tbl.Rows.Add (line); return tbl.ToString ();} write the table in the //somepage.aspx devail function menu (helper, toplayernumber) { Replace ucMainMenu with var sublayertable; var sublayerpostcompileID; menuHelper_Part1 (); function menu on_part1 () {// ucMainMenu_pnlContent sublayerpostcompileID = toplayer.replace ("ucMainMenu", "ucMainMenu_pnlContent"); // WebMebt WebberNet Call. Menu on the WebSaver SBI menu_helper (toplayernumber, menuito_part2); } Function Menu Helper_Part2 (Results) {// Enter result in target field document. GetElementById (sublayerpostcompileID). WinnerHTML = Results; }}  

When I return it to JavaScript JavaScript just writes "System.Web.UI.HtmlControls.HtmlTable".

How do I get to write this actual table?

Only one issue with your code is "tbl.ToString ()" used.

As mentioned in some other terms, you should give a control to the stringbuilder object by using a HtmlTextWriter, which is then something like string value for your method:

protected string tablemaker () {HtmlTable tbl = new HtmlTable (); HtmlTableCell cell = new HtmlTableCell (); HtmlTableRow line = new HtmlTableRow (); Cell.InnerText = "whatever text"; Row.Cells.Add (cell); Tbl.Rows.Add (line); Stringbilder sb = new stringbiller (); (String Vitter Slow = New String Vitter (SB)) (HtmlTextWriter tw = New HtmlTextWriter (sw)) {tbl.RenderControl (tw); }} Return sb.ToString (); }

You must return HTML to be inserted into your page.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -