468,140 Members | 1,454 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,140 developers. It's quick & easy.

Best way to dump HTML strings to a page in ASP.Net?

I'm currently work'n on a project where I'm dynamically generating some
HTML as text into a string builder. My ASP page has a <span> tag on it
and after I gernerate HTML to my string builder I concat all the
strings and set the span's innerHTML property to this output. What I'm
wondering is if this is the best way to do this or is there a better
method to take a bunch of strings and dump them out onto an ASP page so
it shows up as formatted HTML? Second of all, this method seems to work
fine when my text has a lower number of strings, if I have a lot of
strings however it outputs to the page correctly but strangely enough
other portions of my page stop working (like my seach box will no
longer work, this only happens with a high number of strings being
concat'ed though, like 100+)? Any insights would be appreciated!

Jun 28 '06 #1
3 1764
asp:Literal
<ma******@gmail.com> wrote in message
news:11**********************@d56g2000cwd.googlegr oups.com...
I'm currently work'n on a project where I'm dynamically generating some
HTML as text into a string builder. My ASP page has a <span> tag on it
and after I gernerate HTML to my string builder I concat all the
strings and set the span's innerHTML property to this output. What I'm
wondering is if this is the best way to do this or is there a better
method to take a bunch of strings and dump them out onto an ASP page so
it shows up as formatted HTML? Second of all, this method seems to work
fine when my text has a lower number of strings, if I have a lot of
strings however it outputs to the page correctly but strangely enough
other portions of my page stop working (like my seach box will no
longer work, this only happens with a high number of strings being
concat'ed though, like 100+)? Any insights would be appreciated!

Jun 28 '06 #2
yeah, a literal seems to be a better way to go.

However, even after I switched it to that I'm still having problems
with how much HTML I'm allowed to post to the text property of the
literal. Is there some kinda of limit on how much data you can assign
to the text property?

Here's the specific effect I'm seeing.... I have a custom built seach
box which is simply a button and a text box which has an OnClick method
that uses Response.Redirect to redirect to a URL adding a query string.
On this results page I have a asp:Literal tag and I generate a bunuch
of HTML as strings into a string builder. After all my strings are
generated I say nameOfLiteral.Text = nameOfStringBuilder.ToString();
The page always shows the correct dynamically generated HTML so it
seems the data is getting into the text property of the Literal and
displayed on the page... however, when I don't have that much HTML
added to the Literal my search box works as normal, when I add much
more HTML to the literal control my search box stops working and
generates a scrip error in IE. So it seems as if the text is getting to
the literal ok but for some reason a lot of text as opposed to a little
breaks my page. Any suggestions on a fix for this?

sloan wrote:
asp:Literal
<ma******@gmail.com> wrote in message
news:11**********************@d56g2000cwd.googlegr oups.com...
I'm currently work'n on a project where I'm dynamically generating some
HTML as text into a string builder. My ASP page has a <span> tag on it
and after I gernerate HTML to my string builder I concat all the
strings and set the span's innerHTML property to this output. What I'm
wondering is if this is the best way to do this or is there a better
method to take a bunch of strings and dump them out onto an ASP page so
it shows up as formatted HTML? Second of all, this method seems to work
fine when my text has a lower number of strings, if I have a lot of
strings however it outputs to the page correctly but strangely enough
other portions of my page stop working (like my seach box will no
longer work, this only happens with a high number of strings being
concat'ed though, like 100+)? Any insights would be appreciated!


Jun 28 '06 #3
k, I got it figured out now, or at least a solution with a plausable
explaination. Thought I'd repost in case anybody else has this problem
in the future. I tried running my page in FireFox and it worked there
but not in IE. After a little research it seems that IE has different
limitations for query strings or hidden fields than other browers...
apparently FireFox supports more data than IE in this respect which
would explain why it worked in FireFox but not in IE. Because I was
using GET for the form method this also made a difference (again
seemingly a difference between browsers). By changing the the form
method to POST (which is generally used for larger amounts of data) the
problem was solved in IE. Moral of the story is that if there's a lot
of data being passed in a query string or hidden feild make sure your
form method is POST so it has more room to pass your data along.

Dave Mathew wrote:
yeah, a literal seems to be a better way to go.

However, even after I switched it to that I'm still having problems
with how much HTML I'm allowed to post to the text property of the
literal. Is there some kinda of limit on how much data you can assign
to the text property?

Here's the specific effect I'm seeing.... I have a custom built seach
box which is simply a button and a text box which has an OnClick method
that uses Response.Redirect to redirect to a URL adding a query string.
On this results page I have a asp:Literal tag and I generate a bunuch
of HTML as strings into a string builder. After all my strings are
generated I say nameOfLiteral.Text = nameOfStringBuilder.ToString();
The page always shows the correct dynamically generated HTML so it
seems the data is getting into the text property of the Literal and
displayed on the page... however, when I don't have that much HTML
added to the Literal my search box works as normal, when I add much
more HTML to the literal control my search box stops working and
generates a scrip error in IE. So it seems as if the text is getting to
the literal ok but for some reason a lot of text as opposed to a little
breaks my page. Any suggestions on a fix for this?

sloan wrote:
asp:Literal
<ma******@gmail.com> wrote in message
news:11**********************@d56g2000cwd.googlegr oups.com...
I'm currently work'n on a project where I'm dynamically generating some
HTML as text into a string builder. My ASP page has a <span> tag on it
and after I gernerate HTML to my string builder I concat all the
strings and set the span's innerHTML property to this output. What I'm
wondering is if this is the best way to do this or is there a better
method to take a bunch of strings and dump them out onto an ASP page so
it shows up as formatted HTML? Second of all, this method seems to work
fine when my text has a lower number of strings, if I have a lot of
strings however it outputs to the page correctly but strangely enough
other portions of my page stop working (like my seach box will no
longer work, this only happens with a high number of strings being
concat'ed though, like 100+)? Any insights would be appreciated!


Jun 28 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Ravi Tallury | last post: by
6 posts views Thread by Eric Robinson | last post: by
136 posts views Thread by Matt Kruse | last post: by
5 posts views Thread by Andrew | last post: by
4 posts views Thread by Együd Csaba | last post: by
14 posts views Thread by Sheldon | last post: by
13 posts views Thread by Justin.Voelker | last post: by
4 posts views Thread by trullock | last post: by
27 posts views Thread by didacticone | last post: by
1 post views Thread by gcdp | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.