I creating asp.net c# web application.
I have a linkButton (lnkDelete) on first column of each row of gridview.
Also i am adding an attribute dynamically to that link button inside “RowDataBound” event of GridView.
Like as follows :
lnkDelete.Attributes.Add("onclick", "javascript:return confirm('Are you sure you want to delete this Product :" +
DataBinder.Eval(e.Row.DataItem, "ProductName") + "')");
Now What i am trying to do is when user click that link button a javascript confirm popup open up ,asking “Are you sure you want to delete this product”.
Every thing work fine . But Problem occures when the name of the products comes with sngle quote.
Like : Product’One.
Syntax Error comes in ErrorConsole (javascript) when i click lnkDelete and error is : ( illegal character )
I know the problem is with single quote.
Please suggest me what change required in my above code.
I hope i am clear.
How about adding
\in the single quote?