views:

20

answers:

2

Given a textbox:

<asp:Textbox runat="server" id="txtAddress1" />

This renders as something similar to:

<input name="ctl00$mainContent$txtAddress1" type="text" id="ctl00_mainContent_txtAddress1" />

I don't think browsers autocomplete features recognise this name/ID as a field they can autofill, they are not standard recognised names.

Is there any way to overide the client ID's so that autocomplete has a better chance of recognising them?

+3  A: 

2 Points with this.

1) The "Override the Name" feature was introduced in ASP.Net 4.0, where for any property you can choose a hardcoded name instead of the dynamic name. You need to be careful on this as you don't want 2 objects sharing a name.

2) ASP.Net 2.0 and above (may have been in v1.0) has a property on the control called "AutoCompleteType" which provides a hint to the browser on what sort of information is required in the box.

DJIDave
+1  A: 

Assuming you're using Asp.net 4.0, and you're aware of the points mentioned by DJIDave, you can use the ClientIDMode property on a control, and set it to 'Static'. Then, what ever you specify in the Id field in Asp.Net will be brought through to your final markup, and will not be 'mangled' (for want of a better word) by Asp.Net.

elkdanger