I was attempting to use a LinkButton in an ASP.Net WebForms application and I was receiving the following error which occurred simply on a PostBack with no other code.
Line: 1 Error: The value of the property '__doPostBack' is null or undefined, not a Function object
There are many blog posts that tell you that one cause of this is ASP.Net not correctly detecting your browser. It uses browser definition files and when new browsers come out it doesn't quiet know what to do with it without a manual intervention or an update from Microsoft. Here are the links where Scott Hansleman explains these scenarios:
HtmlEncode and UrlEncode Now Encode Single Quotation Marks
In ASP.NET 4, the HtmlEncode and UrlEncode methods of the HttpUtility and HttpServerUtility classes have been updated to encode the single quotation mark character (') as follows:
- The HtmlEncode method encodes instances of the single quotation mark as ' .
- The UrlEncode method encodes instances of the single quotation mark as %27.
<asp:LinkButton ID="linkViewCoverLetter" runat="server" Text="View Cover Letter" href="#" OnClientClick="__doPostBack('linkButtonTest','')"></asp:LinkButton>
Update: You may additionally need to add a CausesValidation="false" property to the LinkButton. I ran into an issue in a server control on an HTML5 site that wouldn't work without that additionally being set.
Is this a great workaround? Probably not and it may not be ideal for your scenario. Will it work. Yup. I've tested it in Chrome 45, IE 10/11 and Firefox 40.0.3.