Response.Write Placement

G

Guest

Hi,
I currently am generating a report by to my end user by retrieving data from
my back end DB
and concatenating strings together and place this string concatenation
within a Label control.

I am finding some efficiencies issues and would like to use Response.Write()
and stream this information directly
to the aspx page. All of my code is in the code behind and i would like to
keep it there.

How can i place the Response.Write stream in the Label control?
And is this possible.

Thanks,
Ron
 
G

Guest

Ron,
In a word, you don't. You take the string that you were going to
Response.Write and you assign it to the Text property of the label.
Peter
 
M

Mark Fitzpatrick

Ron,
You can't stream it directly into a specific location using
Response.Write.

Have you tried using a StringBuilder? That usually nukes most of the
string concatenation overhead and you can then just set the label's text
property to the stringbuilders output through ToString().

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
 
G

Guest

The problem is size of the string is so large that it is not effcient to use
stringbuilder or string concats this i got from Q306821

"If you are in an environment that supports streaming the data, such as in
an ASPX Web Form or your application is writing the data to disk, consider
avoiding the buffer overhead of concatenation or the StringBuilder, and write
the data directly to the stream through the Response.Write method or the
appropriate method for the stream in question."

Some of the reports can have thousands of lines to them. This is way i would
like to use Response.Write.

Thanks for quick repsonse.
Ron
 
S

Swanand Mokashi

I would suggest using the StringBuilder class to concat strings -- it is a
lot more efficient than just string concats :

str1 = str1 + "test 1";

In this case 3 string objects are created where as if you use StringBuilder
, it uses a buffer :

System.Text.StringBuilder str = new System.Text.StringBuilder();
str.Append("test 1");

you can also use the AppendFormat method if you want to format the string
that is being appended

HTH
--
Swanand Mokashi
Microsoft Certified Solution Developer (.NET) - Early Achiever
Microsoft Certified Application Developer (.NET)

http://www.dotnetgenerics.com/
DotNetGenerics.com -- anything and everything about Microsoft .NET
technology ...

http://www.swanandmokashi.com/
http://www.swanandmokashi.com/HomePage/WebServices/
Home of the Stock Quotes, Quote of the day and Horoscope web services
 
G

Guest

Could i use the Response.Write to generate the HTML Markup in the code behind
of an aspx page?
 
G

Guest

The problem is the size of the reports that are built form the DB currently
we have been using the string concats method but we are have a lot of issues
with timeouts. Thats why i would like to use Response.Write.
 
G

Guest

What about some controls that i use on the page?
I currently ise a couple of command butons to print and close the report and
a text box to hold the date from a scripted based date picker.

How would that work? If you like i can send you my current code behind and
aspx html code so you may have a better understanding of what i am doing but
i would rather not post it here in the group becuse of sensitivity issues and
security.

Thanks,
Ron
 
M

MSDN

Ron,

I have seen an entire web application build programmatically.
Not even a single static html tag.
I am not saying that is the best solution but you can do it.

Yes create everything programmatically including your buttons. Everything.
<html> <head>..<script>...</script>.<style></style></head>
<body><input..button.onclick='...'.>[Your report using tables etc..]
input..onclick=....></body></html>
This makes it more difficult to maintain in the future etc....

But as other have said: Have you used the StringBuilder instead and does it
help you at all.

Where is the speed problem???

SA
 
M

Mark Fitzpatrick

Did you try using the StringBuilder? StringBuilder is not the same as string
concatenation and was designed to avoid the problems associated with typical
string concat performance.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top