Im using asp.net Telerik Grid and i need to call a javascript method inside of it. as parameters im passing string for that method. that string can contain special characters such as ',",/,\ ect.
when that string contains those special characters, the javascript function is not calling.
so i used HttpUtility.HtmlEncode(string) for this and this is working for some special characters and wont work for some.
below is my code.
<telerik:GridTemplateColumn>
<ItemTemplate>
<%#"<a onclick='" +( ((string)((Container as GridDataItem).GetDataKeyValue("Type")) == "Additional")? ("showAdditionalPositionNoteEdit("+ (Container as GridDataItem).GetDataKeyValue("ID")+ ",\""+HttpUtility.HtmlEncode((Container as GridDataItem).GetDataKeyValue("Note"))+"\")"): ("showDialog2("+ (Container as GridDataItem).GetDataKeyValue("ID")+ ",\""+HttpUtility.HtmlEncode((Container as GridDataItem).GetDataKeyValue("Note"))+"\")")) + ";return false;'>Edit Notes</a>"%>
</ItemTemplate>
</telerik:GridTemplateColumn>
this part is the one that need a solution. HttpUtility.HtmlEncode((Container as GridDataItem).GetDataKeyValue("Note"))
This note can contain any special character. and i need to do this on clientside