从我的代码后面我传递这对客户端脚本如何在JavaScript
C#代码背后 * 注:如果我的评论下面对付“&”,“(”,“)”线比我没有得到js错误。 *
if (btnDelete != null)
{
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"));
}
//javascript
function DeleteRow(rowId, rowIdx, Id, Name) {
var result = confirm('Are you sure you want to delete this record? \n\n Id: ' + Id + "\n Name: " + Name);
if (!result)
HighlightRow(rowId, rowIdx % 2 ? "#DEEEE9" : "#FFFFFF");
return result;
}
错误消息:
Message: Unterminated string constant
Line: 1280
Char: 180
Code: 0
URI: http://localhost:4964/admin/default.aspx
Message: Unterminated string constant
Line: 1341
Char: 178
Code: 0
URI: http://localhost:4964/default.aspx
Message: Expected ')'
Line: 1401
Char: 152
Code: 0
URI: http://localhost:4964/default.aspx
难道这就是[同样的问题之前(http://stackoverflow.com/questions/4997634/how-to-escape-逗号在JavaScript的)? – user113716 2011-02-15 02:30:20