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

Discussion in 'ASP .Net' started by mathewda@gmail.com, Jun 28, 2006.

  1. Guest

    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, 2006
    #1
    1. Advertising

  2. sloan Guest

    asp:Literal


    <> wrote in message
    news:...
    > 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!
    >
    sloan, Jun 28, 2006
    #2
    1. Advertising

  3. Dave Mathew Guest

    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
    >
    >
    > <> wrote in message
    > news:...
    > > 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!
    > >
    Dave Mathew, Jun 28, 2006
    #3
  4. Dave Mathew Guest

    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
    > >
    > >
    > > <> wrote in message
    > > news:...
    > > > 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!
    > > >
    Dave Mathew, Jun 28, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. halfdog
    Replies:
    12
    Views:
    12,409
  2. Ben

    Strings, Strings and Damned Strings

    Ben, Jun 22, 2006, in forum: C Programming
    Replies:
    14
    Views:
    732
    Malcolm
    Jun 24, 2006
  3. Diego Martins
    Replies:
    5
    Views:
    5,245
    Diego Martins
    Jun 19, 2007
  4. W. Martin Borgert
    Replies:
    3
    Views:
    1,833
    W. Martin Borgert
    Jan 12, 2011
  5. John Trupiano
    Replies:
    1
    Views:
    166
    John Trupiano
    Sep 5, 2008
Loading...

Share This Page