admin管理员组文章数量:1225015
EDIT1:
btnDelete.Attributes.Add("onclick", String.Format(@"return DeleteRow('{0}',{1},{2},{3});", e.Row.ClientID, e.Row.RowIndex, DataBinder.Eval(e.Row.DataItem, "Id"), "'" + DataBinder.Eval(e.Row.DataItem, "Name") + "'"));
edit:
i get this error:
Message: Unterminated string constant
i am passing the value from code behind and some of my text have somethinh lke this:
Foo3, In.c
//javascript
function DeleteRow(rowId, rowIdx, Id, Name) {
var textForMessage = "return confirm('Are you sure you want to delete this record with the name: \n{0} \n{1}');";
//removed code...
return result;
}
EDIT1:
btnDelete.Attributes.Add("onclick", String.Format(@"return DeleteRow('{0}',{1},{2},{3});", e.Row.ClientID, e.Row.RowIndex, DataBinder.Eval(e.Row.DataItem, "Id"), "'" + DataBinder.Eval(e.Row.DataItem, "Name") + "'"));
edit:
i get this error:
Message: Unterminated string constant
i am passing the value from code behind and some of my text have somethinh lke this:
Foo3, In.c
//javascript
function DeleteRow(rowId, rowIdx, Id, Name) {
var textForMessage = "return confirm('Are you sure you want to delete this record with the name: \n{0} \n{1}');";
//removed code...
return result;
}
Share
Improve this question
edited Feb 14, 2011 at 22:07
Nick Kahn
asked Feb 14, 2011 at 21:44
Nick KahnNick Kahn
20.1k97 gold badges284 silver badges416 bronze badges
4
|
5 Answers
Reset to default 11Do nothing. A comma has no special meaning inside a JavaScript string.
You don't need to escape the comma. You should surround the entire string with quotes:
'Foo3, In.c'
If this string is inside another string which is also single-quoted you may need to escape the quotes.
If the error is client side you can solve it by having:
btnDelete.Attributes["onclick"] = String.Format("return DeleteRow('{0}', '{1}', '{2}', '{3}');", e.Row.ClientID, e.Row.RowIndex, DataBinder.Eval(e.Row.DataItem, "Id"), DataBinder.Eval(e.Row.DataItem, "Name").ToString().Replace("'", "\'"));
If it's server side, please post the full error message plus stack trace.
\x2c
Useful in ajax.
function myfunction(id, str_URL) {
$.ajax({
type: "GET",
url: str_URL,
success: function(t) {
var link = "<a href=\x22JavaScript:MyJava(\x22Param1\x22\x2c\x22Param2\x22)\x22>Link text</a>";
}
});
}
\x22
is "
(quote)
Just reference the Hex column in the ascii table.
http://www.asciitable.com/index/asciifull.gif
If your trying to escape a throw error due to comas that you need in a non quoted could be string datatype. say you needed it that way post.example, + post.example,
var comma =",";
post.example.concat(comma) + post.example.concat(comma)
Using concat method will concatenate any variable type.
本文标签: aspnetHow to ESCAPE quotcommaquot in JavascriptStack Overflow
版权声明:本文标题:asp.net - How to ESCAPE "comma" in Javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1739447966a2163557.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
Foo3, In.c
then where is this value passed? Even if it is passed as one of the parameters, you are not doing anything with them... Please provide a more complete/correct/whatever example. – Felix Kling Commented Feb 14, 2011 at 21:50