473,326 Members | 2,173 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Adding HTML Code to a web page already running

This is probably a simple question, but I just started using C# and I
haven't done any projects like this before, however, I need to know if
there is a way to accomplish what I am currently doing in a faster
time. Right now I have a web page I created in VS 2005 where I am
pulling data from a database dependant upon who is logged in and
showing them the members and information for their specific company.
However, to display this on the web page I created a label and I simply
add the html code to that label. This seems to take a good 5 minutes
as some of the companies have 1200 some people and that means 3600
lines of html are added to this label. So basically is there a faster
way to take that code and add it to the page? Right now I have an
outside program create a file with the company name beforehand and this
file contains all the HTML I want to add. Sorry if this is confusing,
but I would greatly appreciate any help or ideas.

Thanks,

Dan

Oct 6 '06 #1
3 1647
This is probably a simple question, but I just started using C# and I
haven't done any projects like this before, however, I need to know if
there is a way to accomplish what I am currently doing in a faster
time. Right now I have a web page I created in VS 2005 where I am
pulling data from a database dependant upon who is logged in and
showing them the members and information for their specific company.
However, to display this on the web page I created a label and I simply
add the html code to that label. This seems to take a good 5 minutes
as some of the companies have 1200 some people and that means 3600
lines of html are added to this label. So basically is there a faster
way to take that code and add it to the page? Right now I have an
outside program create a file with the company name beforehand and this
file contains all the HTML I want to add. Sorry if this is confusing,
but I would greatly appreciate any help or ideas.

Thanks,

Dan
How are you building that HTML?
If you are using a string where you add each line to, then it is much
faster to use StringBuilder:

instead of:

string s = "";
for (int i=0; i<rows.Count; i++)
{
s = s + HtmlForRow(rows[i]);
}
LabelOutput.Text = s;

use this:

System.Text.StringBuilder sb = new System.Text.StringBuilder();
for (int i=0; i<rows.Count; i++)
{
sb.Append(HtmlForRow(rows[i]));
}
LabelOutput.Text = sb.ToString();

see also http://www.yoda.arachsys.com/csharp/stringbuilder.html
Hans Kesting
Oct 6 '06 #2

Hans Kesting wrote:
This is probably a simple question, but I just started using C# and I
haven't done any projects like this before, however, I need to know if
there is a way to accomplish what I am currently doing in a faster
time. Right now I have a web page I created in VS 2005 where I am
pulling data from a database dependant upon who is logged in and
showing them the members and information for their specific company.
However, to display this on the web page I created a label and I simply
add the html code to that label. This seems to take a good 5 minutes
as some of the companies have 1200 some people and that means 3600
lines of html are added to this label. So basically is there a faster
way to take that code and add it to the page? Right now I have an
outside program create a file with the company name beforehand and this
file contains all the HTML I want to add. Sorry if this is confusing,
but I would greatly appreciate any help or ideas.

Thanks,

Dan

How are you building that HTML?
If you are using a string where you add each line to, then it is much
faster to use StringBuilder:

instead of:

string s = "";
for (int i=0; i<rows.Count; i++)
{
s = s + HtmlForRow(rows[i]);
}
LabelOutput.Text = s;

use this:

System.Text.StringBuilder sb = new System.Text.StringBuilder();
for (int i=0; i<rows.Count; i++)
{
sb.Append(HtmlForRow(rows[i]));
}
LabelOutput.Text = sb.ToString();

see also http://www.yoda.arachsys.com/csharp/stringbuilder.html
Hans Kesting
Basically what I do is, go through with a reader from my query, then I
parse it into a line of code, say <td align.... " +
rdr.getValue().ToString().Trim() + " >"
and then I simply write that to a text file named after the company.
Then basically the text file looks like the html code for a number of
tables. After that program finishes, I have it so that in the C# code
for my page it simply opens the file and reads the lines in 1 at a time
and stores them into the label like this :

temp = sr.ReadLine();
txt_summary += temp;

thanks for your reply and I'll look into the StringBuilder information.

Dan

Oct 6 '06 #3

DFDavis wrote:
Hans Kesting wrote:
This is probably a simple question, but I just started using C# and I
haven't done any projects like this before, however, I need to know if
there is a way to accomplish what I am currently doing in a faster
time. Right now I have a web page I created in VS 2005 where I am
pulling data from a database dependant upon who is logged in and
showing them the members and information for their specific company.
However, to display this on the web page I created a label and I simply
add the html code to that label. This seems to take a good 5 minutes
as some of the companies have 1200 some people and that means 3600
lines of html are added to this label. So basically is there a faster
way to take that code and add it to the page? Right now I have an
outside program create a file with the company name beforehand and this
file contains all the HTML I want to add. Sorry if this is confusing,
but I would greatly appreciate any help or ideas.
>
Thanks,
>
Dan
How are you building that HTML?
If you are using a string where you add each line to, then it is much
faster to use StringBuilder:

instead of:

string s = "";
for (int i=0; i<rows.Count; i++)
{
s = s + HtmlForRow(rows[i]);
}
LabelOutput.Text = s;

use this:

System.Text.StringBuilder sb = new System.Text.StringBuilder();
for (int i=0; i<rows.Count; i++)
{
sb.Append(HtmlForRow(rows[i]));
}
LabelOutput.Text = sb.ToString();

see also http://www.yoda.arachsys.com/csharp/stringbuilder.html
Hans Kesting

Basically what I do is, go through with a reader from my query, then I
parse it into a line of code, say <td align.... " +
rdr.getValue().ToString().Trim() + " >"
and then I simply write that to a text file named after the company.
Then basically the text file looks like the html code for a number of
tables. After that program finishes, I have it so that in the C# code
for my page it simply opens the file and reads the lines in 1 at a time
and stores them into the label like this :

temp = sr.ReadLine();
txt_summary += temp;

thanks for your reply and I'll look into the StringBuilder information.

Dan
Just a quick update, the StringBuilder worked perfectly, thanks a lot.

Dan

Oct 6 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Josh Mayfield | last post by:
Note: There is considerable background detail here, but I do have three questions, which are clearly marked and appear right before the sample code. I have a legitimate need to launch an EXE...
20
by: David | last post by:
I have a one-line script to add an onunload event handler to the body of the document. The script is as follows: document.getElementsByTagName("BODY").onunload=function s() {alert("s")} Now...
2
by: laredotornado | last post by:
Hello, I am looking for a cross-browser way (Firefox 1+, IE 5.5+) to have my Javascript function execute from the BODY's "onload" method, but if there is already an onload method defined, I would...
1
by: Andrew | last post by:
Hey all, I am very new to ASP.Net (and .Net in general), but that isn't stopping the boss from wanting to begin new projects in it. This latest project has me kinda stumped and after a couple...
3
by: Ankit Aneja | last post by:
I have a strange situation and I have no idea how to solve this. Its a Recruitment Search Page,in the Admin Page, for every button click event the Admin Person has to create a checkbox on the users...
9
by: Neo Geshel | last post by:
I have strip-mined, strip-searched, and completely exhausted the Internet (up to the 30th page on Google, with 100 results per page!!), all without finding an answer to my question AS TO WHY IT...
0
by: dfdavis.mtu | last post by:
This is probably a simple question, but I just started using C# and I haven't done any projects like this before, however, I need to know if there is a way to accomplish what I am currently doing...
2
by: ChrisCicc | last post by:
Hi All, I got a real doozy here. I have read hundreds upon hundreds of forum posts and found numerous others who have replicated this problem, but have yet to find a solution. Through testing I have...
15
by: lxyone | last post by:
Using a flat file containing table names, fields, values whats the best way of creating html pages? I want control over the html pages ie 1. layout 2. what data to show 3. what controls to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.