You did not provide the markup from your .aspx code. But most likely the ID that is generated for you TextBox is different due to ClientIdMode. You can view the generated HTML for your page if you're not sure.
What you should do is set the ClientIdMode for your TextBox to Static. Then the ID on the client side will be "txtName".
<asp:TextBox runat="server" id="txtName" ClientIdMode="Static" />
For more info, see MSDN ASP.NET Web Server Control Identification.
You can set the ClientIdMode for all controls on all pages with a single setting in your web.config.
<configuration>
<system.web>
<pages clientIDMode="Static"></pages>
</system.web>
</configuration>
I got the directions for this here.
Another way is to put ASP.NET inline to give JavaScript the ClientId. This has the advantage that if you delete or rename txtName for some reason, it'll cause a compilation error instead of silently failing at runtime.
$("#<%= txtName.ClientID %>").autocomplete();