473,406 Members | 2,707 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,406 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 1650
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.