thank you for the answer. this is what i came up with and it finally works:
string varValue = drRDK[strValue].ToString().Replace("\\",
"\\\\").Replace("'", "\\'").Replace(@"""", @"""""");
strValues += @"<tr><td><a href=""#"" onclick=""javascript
:" + strTextBox
+ ".value='" + varValue + "';" + strDiv + ".style.visibility='hidden';" +
strDiv + @".innerHTML='';"">" + strOutput + "</a></td></tr>" + "\n\r";
do u know anything about html? cause that code above works :), but the
javascript it produces sometimes doesn't. this is something the above
generates that doesn't work:
<tr><td><a href="#"
onclick="javascript
:ctl00_ctl00_cphMainContent_cph Customers_tbName.value='DOUBLE
""H"" ENTERPRISES
INC';divOfNames.style.visibility='hidden';divOfNam es.innerHTML='';">14585 -
DOUBLE "H" ENTERPRISES INC</a></td></tr>
how can i get the ""H"" to work right. thank you
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Abraham Luna <ab*@rdk.com> wrote: can anyone tell me why this string throws an error:
strValues += "<tr><td><a href=\"\#\" onclick=\"javascript:" + strTextBox
+
".value='" + drRDK[strValue].ToString().Replace("\\",
"\\\\").Replace("'",
"\\'").Replace('"', '""') + "';" + strDiv + ".style.visibility='hidden';"
+
strDiv + ".innerHTML='';\">" + strOutput + "</a></td></tr>\n\r";
my code edit colors it correctly but it throws an error
please help
# doesn't need escaping - where you've got \#, that's an illegal escape
code.
Note that your code would be *much* easiest to read if you'd break each
bit onto a different line, even if you still have it within the same
statement. For example:
strValues += "<tr><td><a href=\"\#\" onclick=\"javascript:" +
strTextBox +
".value='" +
drRDK[strValue].ToString()
.Replace("\\", "\\\\")
.Replace("'", "\\'")
.Replace('"', '""') +
"';" +
strDiv +
".style.visibility='hidden';" +
strDiv +
".innerHTML='';\">" +
strOutput +
"</a></td></tr>\n\r";
Using a StringBuilder and breaking it up further would almost certainly
add more to the readability too - *and* make it easier to find out
where the error is when you get one.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too