I have a gridview and inside the gridview, I have a label and when the user clicks on that label, I invoke a javascript function. I passw few values from that label to javascript function. If the values has apsotrphe in it. It generates an error and does not invke javascript function. Below is my code.
<asp:TemplateField>
<ItemTemplate>
<label style="text-decoration: underline" onclick="javascript:GetSelectedRow('<%# Eval("ID") %>','<%# Eval("systempath") %>','','',1);"><%#Eval("ID") %></label>
</ItemTemplate>
</asp:TemplateField>
and the javascript function is
function GetSelectedRow(id, systempath, x, x, rowIndex) {
debugger;
var label = document.getElementById('<%=lbl_ID.ClientID %>');
label.innerText = mclid + "|" + systempath;
document.getElementById('<%=hdnlblID.ClientID %>').value = id + "|" + systempath;
return false;
}
Try this