double quote - "\""


hello there...
 i tried everything of think but not working the way i wanted to be... not sure what i'm missing...
i'm generating a in code behind and then using in javascript....
here is what i'm doing
code behind:

int
i=0
string _keywordID = "keyword";
string _name = row["visit_info_nm"].ToString().Trim();
String _getElementByID = String.Format("{3}<br>", i, _keywordID, _name, _name);
here is what it generate :
First Day
and i copy the above line and paste in a html like this..
<input type="text" id="keyword">
First Day
i get error:
Unterminated string constant
what i'm missing?

Its all about coding!
0
nisarkhan
3/29/2007 3:03:34 PM
๐Ÿ“ asp.net.getting-started
๐Ÿ“ƒ 91979 articles.
โญ 4 followers.

๐Ÿ’ฌ 5 Replies
๐Ÿ‘๏ธโ€๐Ÿ—จ๏ธ 4205 Views



This:
String _getElementByID = String.Format("<span id='{0}' OnClick = \"document.getElementById
Should be
String _getElementByID = String.Format("<span id='{0}' OnClick = ""document.getElementById
The escape for a " is to double it in vb.net ""

0
Curt_C
3/29/2007 4:25:21 PM

            
Curt_C:

This:
String _getElementByID = String.Format("<span id='{0}' OnClick = \"document.getElementById

Should be
String _getElementByID = String.Format("<span id='{0}' OnClick = ""document.getElementById

The escape for a " is to double it in vb.net ""



does not work.. . here is what i'm doing..


String _getElementByID = String.Format("<span id='{0}' OnClick = ""document.getElementById('{1}').value='{2}';\"">{3}</span><br>", i, _keywordID, _name, _name);
thanks.

Its all about coding!
0
nisarkhan
3/29/2007 5:33:57 PM

1) isn't it onclick or onClick and not OnClick? (not sure if its case sensitive.
2) lose the \ at the end, after the ;..... that's not a valid item.
3) try with hard coded values first... just to test, then work with the {x} code....

0
Curt_C
3/29/2007 8:51:37 PM

Javascript is case-sensitive, HTML is not.  Onclick is a javascript event handler, however, in this case it is an attribute of an HTML element, therefore it's case is irrelevant.
Something you do need to remove, is the spaces between onclick and the equal sign.

Josh Stodola   โ† Come check out my blog!
0
JoshStodola
3/29/2007 9:01:43 PM

hi,
i have modifed the code for you, you can take a try and see if your problem still exisits:
String _getElementByID = String.Format("{3}<br>", i, _keywordID, _name, _name);
PS: to output a " in the html response, use \" in code behind and usd " directly in your page mark up;
      to output a ' iin the html response, use \' in code behind and use ' directly in your page mark up.
 

Please remember to click โ€œMark as Answerโ€ on the post that helps you, and to click โ€œUnmark as Answerโ€ if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
0
Bo
4/9/2007 6:02:55 AM
Reply: