Results 1 to 6 of 6

Thread: [Resolved] Store HTML code as string?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624

    [Resolved] Store HTML code as string?

    Is there a more efficient way of doing this than adding &""""& for every double quotation mark in the html code when building the string? I need to store the HTML code as a string. I am finding "[tablerow]" within an existing document with StreamReader and want to replace it with my string value (html code) when writing it back using stringwriter.
    Last edited by hipopony66; Feb 25th, 2009 at 03:20 PM. Reason: Resolved

  2. #2
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: Store HTML code as string?

    If you do two quotes "" inside of a quote, then it will read that as a single quote to be put in the quotes. Example:

    Code:
            Dim s As String
            s = String.Format("""{0}""", "somevalue")
    
            MessageBox.Show(s)

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624

    Re: Store HTML code as string?

    Hmmm. It still does not appear to like that. I am dealing with multiple HTML properties in the string, so there are lots of ""'s. Here's what I've got now:

    Code:
      strRowToAdd = (String.Format("""{0}""", "<tr><td width="16%"><div align="center" class="style4">[procedure]</div></td><td width="16%"><div align="center" class="style4">[date]</div></td><td width="16%"><div align="center" class="style4">[surgeon]</div></td><td width="16%"><div align="center" class="style4">[surgphone]</div></td><td width="16%"><div align="center" class="style4">[facility]</div></td><td width="20%"><div align="center" class="style4">[postop]</div></td></tr>"))
    Thanks for any suggestions. This appears to be fairly tricky.

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624

    Re: Store HTML code as string?

    I ran across this article, but am still a little confused regarding the syntax:

    http://www.camelsquadron.com/forums/...?a=topic&t=173

  5. #5
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: Store HTML code as string?

    If you are just building a large string with no replacement values, then forget about String.Format. Inside your string, replace every double quote with two doublequotes.

    Code:
    "<tr><td width=""16%""><div align=""center"" ...

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624

    Re: Store HTML code as string?

    Thanks Negative0, I got things working........all the double quotes had me cross-eyed!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width