Learning Center
Plans & pricing Sign in
Sign Out

Converting a given string to html table in asp_net


  • pg 1
									Converting a given string to html table in asp,net

                                                                                                                                                   NEED TO DOWNLOAD CODE?
                                                                                                                                                         View our list of code

    Home       Bookstore/E-Books               P2P Programmer Forums                   Connect with Wrox         Code Resources


                                Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET                                User Name   User Name       Remember Me?
       Register Now
                                         2.0 Professional                                                                             Password
       View Active Topics                                                                                                                                         Log in
                                           Converting a given string to html table in asp,net
       View Archives                                                                                                                  I forgot my password     Register Now
       View Unanswered
       Topics                            Register         |    FAQ       |         Members List          |      Calendar          |         Today's Posts          |         Search

                                      ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see
                                      the Visual Web Developer 2005 forum.

                                      Welcome,                           user.

                                      Your Google search for '\"string to html table\" in c#' brought you to Wrox Forum. More Wrox Forum search results

                                                                                                                     Thread Tools          Search this Thread          Display Modes

                                        September 8th, 2007, 01:20 PM                                                                                                      #1 (permalink)

                                                                                                                                             Join Date: Jun 2007
                                                                                                                                             Location: hyderabad, AndhraPradesh, India.
                                      ostwald                                                                                                Posts: 24
                                      Authorized User                                                                                        Thanks: 0
                                                                                                                                             Thanked 0 Times in 0 Posts

                                         Converting a given string to html table in asp,net

                                      Hi friends,
                                      Can anyone help me abt this application.
                                      I'm giving a html table string in a text box.(ex: <table><tr><td> ...............</tr></table>) as input.
                                      And it must return me a datatable as an output and the values must be stored in database.
                                      Plz help me this.


                                      Scrum Project Management for $5
                                      Get the tool that sprints as fast as your team. Burndown charts,
                                      sprint tracking, workflow, user and project manager dashboards.
                                      Free for 1 user, teams start at just $5. Download OnTime 2009

                                        September 9th, 2007, 07:14 PM                                                                                                      #2 (permalink)

                                                                                                                                                  Join Date: Aug 2003
                                                      planoie                                                                                     Location: Clifton Park, New York, USA.
                                                      Friend of Wrox                                                                              Posts: 5,391
                                                      Points: 16,330, Level: 55                                                                   Thanks: 0
                                                                                                                                                  Thanked 2 Times in 2 Posts
                                                      Activity: 0%

                                      If the HTML is XHTML compliant you could treat it as XML and get the rows and values from the table using an xml document and
                                      the right set of xpath queries. This would be a fairly elegant way to do it and would probably require the least amount of code. If you
                                      can't expect the input to conform to XHTML then you'll have to write a parser to handle more poorly formed input.

                                      -Peter[6/25/2009 7:28:42 PM]
Converting a given string to html table in asp,net

                                          September 10th, 2007, 04:44 AM                                                                                     #3 (permalink)

                                                                                                                                   Join Date: Jun 2007
                                                                                                                                   Location: hyderabad, AndhraPradesh, India.
                                      ostwald                                                                                      Posts: 24
                                      Authorized User                                                                              Thanks: 0
                                                                                                                                   Thanked 0 Times in 0 Posts

                                      Hey Pete,
                                      Thanx fo ur reply. I achieved the application by parsing. I didn'y use XHTML. I used html text as string and then parsed it to generate
                                      the required criteria. Herez the code.

                                      <%@    Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" ValidateRequest="false" %>
                                      <%@    Import namespace="System.Text" %>
                                      <%@    Import Namespace="System.IO" %>
                                      <%@    Import Namespace="System.Data.SqlClient" %>
                                      <%@    Import Namespace="System.Data" %>

                                      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

                                      <html xmlns="" >
                                      <head runat="server">
                                      <title>Untitled Page</title>
                                      <script language="C#" type="text/C#" runat=server >
                                      private void Post_Text(object sender, EventArgs e)




                                      postmess.Text=parsetext(mess.Text,false) ;

                                      //postmess.Text=parsetext(mess.Text,true) ;

                                      postmess.Text=mess.Text ;
                                      String s = "Select * from htmln";
                                      SqlConnection con = new SqlConnection("Data Source=KIRAN;Initial Catalog=TrylahNewLayout;Persist Security Info=True;User
                                      SqlDataAdapter da = new SqlDataAdapter(s,con);
                                      SqlCommandBuilder cb = new SqlCommandBuilder(da);
                                      DataSet ds = new DataSet("htmln");
                                      da.Fill(ds, "htmln");

                                      DataRow row = ds.Tables["htmln"].NewRow();
                                      row["doc"] = postmess.Text;
                                      da.Update(ds, "htmln");


                                      public string parsetext(string text, bool allow)

                                      StringBuilder sb = new StringBuilder(text) ;

                                      sb.Replace(" "," &nbsp;");


                                      sb.Replace("<","&lt;") ;
                                      sb.Replace(">","&gt;") ;[6/25/2009 7:28:42 PM]
Converting a given string to html table in asp,net


                                      StringReader sr = new StringReader(sb.ToString());
                                      StringWriter sw = new StringWriter();


                                      string temp = sr.ReadLine();

                                      sw.Write(temp+"<br>") ;

                                      return sw.GetStringBuilder().ToString();

                                      <form runat=server ID="Form2">
                                      <table border=1>
                                      <td valign=top>Result</td>
                                      <asp:label text="&nbsp;" id=postmess runat=server Width="68px" />
                                      <tr><td valign=top>Enter Message </td>
                                      <td><asp:textbox Columns="50" Rows="20" TextMode="MultiLine" id=mess runat=server /></td></tr>
                                      <tr><td colspan=2 style="height: 28px"><asp:button onClick="Post_Text" text="Generate!" runat=server ID="Button1" /></td></tr>

                                      Voted "BEST ASP.NET HOST" For 2009
                                      Voted 2009 s Best ASP.NET Host for by asp.netPRO
                                      Magazine, The 5th Straight Year! See Why Every Year More
                                      Developers Choose To Host With DiscountASP.NET, Plus Get 3
                                      MONTHS FREE Sign Up Now!

                                                                                                Previous Thread | Next Thread

                                     Posting Rules

                                      You   may   not   post new threads
                                      You   may   not   post replies
                                      You   may   not   post attachments
                                      You   may   not   edit your posts

                                      vB code is On
                                      Smilies are On
                                      [IMG] code is Off
                                      HTML code is Off
                                      Trackbacks are Off
                                      Pingbacks are On                     Forum Jump
                                      Refbacks are Off                        ASP.NET 2.0 Professional
                                                                              ASP.NET 2.0 Professional                                                                   Go

                                      Similar Threads

                                                               Thread                              Thread Starter               Forum     Replies          Last Post

                                                                                                                                                    February 9th, 2007 05:22
                                      Problem Converting C# to VB.NET in ASP.NET                kwilliams           ASP.NET 2.0 Basics      0

                                                                                                                    ASP.NET 1.x and 2.0                November 30th, 2006
                                      Converting an HTML Form to ASP.Net Form                   k_alidxb75                                  0
                                                                                                                    Application Design                           02:26 AM

                                                                                                                                                       November 25th, 2006
                                      converting the string to integer vb .net 2005             Subjugate           .NET Framework 2.0      1
                                                                                                                                                                 01:18 PM

                                                                                                                                                         October 15th, 2004
                                      Converting asp/vbscript code to                   realgone_           ASP.NET 1.1             2
                                                                                                                                                                  01:10 PM

                                                                                                                    ASP.NET 1.x and 2.0                September 23rd, 2004
                                      return a string with all HTML and ASP tags strippe        ccc_storage                                 2
                                                                                                                    Application Design                            10:43 PM[6/25/2009 7:28:42 PM]
Converting a given string to html table in asp,net

                                      Ads By Google

                                      C# Thread
                                      The latest news & breakthroughs in parallel computing. Visit today!

                                      C# to VB Converter
                                      Most accurate C# to VB converter. Free demo, support, & updates.
                                      Official Guitar Website
                                      Huge Selection of Gibson Guitars! Electric, Acoustic, Custom Guitars.

                                                                          All times are GMT -4. The time now is 08:26 AM.

                                                                                                                            Contact Us - Wrox - Privacy Statement - Top

                                                                                Powered by vBulletin Version 3.6.8
                                                                          Copyright 2000 - 2009, Jelsoft Enterprises Ltd.
                                                                                     2008 Wiley Publishing, Inc[6/25/2009 7:28:42 PM]

To top