Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 22, 2013 04:46 AM by prabu.raveendran
Feb 22, 2013 03:02 AM|LINK
Just a simple question——
If I wanna alert a messagebox in js, I can say：
alert('<%=SomeVariable defined at code-behind%>');
But if I use double quote——"" instead of ''.
This will output a whole string "<%=SomeVariable defined at code-behind%>".
Can anyone tell us when to use single quote, when double one, when we can use either of them together?
Feb 22, 2013 03:48 AM|LINK
I didn't see any difference, and the following code yeilds me the same result -
public string Name = "BillGates";
Hope it helps u...
Feb 22, 2013 04:35 AM|LINK
Also, the two can be used alongside one another when you need to include string literals within your values :
//These two statements are equivalent
alert('My name is "<%= yourName %>"');
alert("My name is '<%= yourName %>");
For some additonal reading on the topic, I recommend checking out this
Stack Overflow discussion.
Feb 22, 2013 04:46 AM|LINK
They are equivalent for all intents and purposes. If you want to use either one inside a string, it is a good idea to use the other one to create the string, as you noted. Other than that, it's all the same.
You can use " inside ' as below,
var str='<div class="test">'