Reputation: 15372
If I have two inputs in a file I've received which are "put together" with aspx
<tr>
<td align="right">
<asp:Label ID="Label1" runat="server" Text="User Name:" CssClass="login_label"></asp:Label></td>
<td style="width: 200px">
<asp:TextBox ID="txtUserName" runat="server" TabIndex="1" Width="200px"></asp:TextBox></td>
<td style="width: 3px" align="left">
<asp:RequiredFieldValidator ID="rfvUserName" runat="server" ErrorMessage="RequiredFieldValidator" ControlToValidate="txtUserName">Required</asp:RequiredFieldValidator></td>
</tr>
<tr>
<td align="right">
<asp:Label ID="Label2" runat="server" Text="Password:" CssClass="login_label"></asp:Label></td>
<td style="width: 200px">
<asp:TextBox ID="txtPassword" runat="server" TabIndex="2" Width="200px" TextMode="Password"></asp:TextBox></td>
<td style="width: 3px">
<asp:RequiredFieldValidator ID="rfvPassword" runat="server" ControlToValidate="txtPassword" ErrorMessage="Required">Required</asp:RequiredFieldValidator></td>
</tr>
How can I add autocapitalize="off"
attribute to the inputs? Whenever I try to add something to this code——well, most of the time——it just totally breaks. But I would like it to be usable on mobile devices. Thanks for your help!
Upvotes: 0
Views: 782
Reputation: 3635
in the code behind:
NameOfInput.Attributes.Add('autocapitalize','off')
that is how you add an attribute to an html element visible by the server.
javascript: be wary this may not work right in all versions of IE. This should be in the document load event
document.getElementById('<%txtUserName.ClientID%>').setAttribute('autocapitalize','off');
jQuery: same warning as above. also this should be in $(docuemnt).ready() function or load event.
$('#<%txtUserName.ClientID%>').attr('autocapitalize','off');
see this question for a better reason why you can't do what you want to here:
Autocapitalize attribute on input element (used for iOS) breaks validation
one last edit:
Apparently from the IOS development docs there is an example where you can add the attribute to your form element.
So maybe you can add it to the form element, which is not an asp namespace control. the validator may cry but you might not get a compile error.
Upvotes: 2