trying to build a string with stringbuilder fails

C

Carlos

Hi,

I've tried to build a htm string using stringbuilder, but having
a problem when using double quotes (") as values. I use the
escape char (\), but it still reports an error. i.e.the
following does not compile:

sb.Append("<TABLE id=\"Table5\" style=\"Z-INDEX: 102; LEFT: 25%; WIDTH: 70%;
POSITION: absolute; TOP: 220px; HEIGHT: 100%\" cellSpacing=\"1\"
cellPadding=\"1\" border=\"0\"><TR><TD align=\"center\" style=\"width:
619px\"><TABLE id=\"HeadATC\" style=\"WIDTH: 100%; HEIGHT: 44px\"
borderColor=\"#000080\" cellSpacing=\"1\" cellPadding=\"7\" rules=\"none\"
bgColor=\"#ffffe0\" border=\"1\" frame=\"box\" runat=\"server\"><TR><TD
align=\"center\" bgColor=\"Gainsboro\"><FONT face=\"Arial, Helvetica, Helv\"
color=\"#00008b\" size=\"4\"><B> <span style=\"font-size: 12pt; color:
#000080\">ATC</span></B></FONT></TD></TR> </TABLE></TD></TR></TABLE>")

Thanks!
 
G

Gareth Erskine-Jones

Hi,

I've tried to build a htm string using stringbuilder, but having
a problem when using double quotes (") as values. I use the
escape char (\), but it still reports an error. i.e.the
following does not compile:

sb.Append("<TABLE id=\"Table5\" style=\"Z-INDEX: 102; LEFT: 25%; WIDTH: 70%;
POSITION: absolute; TOP: 220px; HEIGHT: 100%\" cellSpacing=\"1\"
cellPadding=\"1\" border=\"0\"><TR><TD align=\"center\" style=\"width:
619px\"><TABLE id=\"HeadATC\" style=\"WIDTH: 100%; HEIGHT: 44px\"
borderColor=\"#000080\" cellSpacing=\"1\" cellPadding=\"7\" rules=\"none\"
bgColor=\"#ffffe0\" border=\"1\" frame=\"box\" runat=\"server\"><TR><TD
align=\"center\" bgColor=\"Gainsboro\"><FONT face=\"Arial, Helvetica, Helv\"
color=\"#00008b\" size=\"4\"><B> <span style=\"font-size: 12pt; color:
#000080\">ATC</span></B></FONT></TD></TR> </TABLE></TD></TR></TABLE>")

It works for me. I'm assuming that your actual code doesn't contain
line breaks and that the statement is terminated with a semi-colon.

GEJ
 
N

NitRaGs

Works for me too

StringBuilder sb = new StringBuilder();
sb.Append("<TABLE id=\"Table5\" style=\"Z-INDEX: 102; LEFT: 25%; WIDTH:
70%;POSITION: absolute; TOP: 220px; HEIGHT: 100%\" cellSpacing=\"1\"
cellPadding=\"1\" border=\"0\"><TR><TD align=\"center\" style=\"width:
619px\"><TABLE id=\"HeadATC\" style=\"WIDTH: 100%; HEIGHT: 44px\"
borderColor=\"#000080\" cellSpacing=\"1\" cellPadding=\"7\" rules=\"none\"
bgColor=\"#ffffe0\" border=\"1\" frame=\"box\" runat=\"server\"><TR><TD
align=\"center\" bgColor=\"Gainsboro\"><FONT face=\"Arial, Helvetica, Helv\"
color=\"#00008b\" size=\"4\"><B> <span style=\"font-size: 12pt; color:
#000080\">ATC</span></B></FONT></TD></TR> </TABLE></TD></TR></TABLE>");

Response.Write(sb.ToString());


-NitRaGs
 
C

Carlos

Thank you all for your response. However since the code is not in C#,
bu in VB, It would not work. I figured out finally.. I had to use single
quotes (')
instead of double (")...

Thnaks again
 

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,989
Messages
2,570,207
Members
46,782
Latest member
ThomasGex

Latest Threads

Top