I am trying to add onclientclick attribute to a linkbutton that has been created in the C# code only which gives error. Following is the code for the same :
LinkButton imghelp = new LinkButton();
imghelp.ID = "btnhelp";
imghelp.Text = "<i class = 'fa fa-question-circle-o'></i>";
imghelp.onClientClick = "javascript:ShowHelp(\"" + Languagecode + "\",\"" + context + "\",\"" + subcontext + "\")";
The error is : "System.Web.UI.WebControls.LinkButton does not contain a definition for onClientClick"
you should have to use
imghelp.Attributes.Add("onClientClick", "Your function here");because if you directly add event like you have done in your code it will always throws an error.