Reputation: 9999
Currently my aspx page contains
<input type="text" name="openid_username" />
<input type="text" name="openid_identifier" />
but now i would like to replace them with
<asp:TextBox ID="openid_username" runat="server"></asp:TextBox>
<asp:TextBox ID="openid_identifier" runat="server"></asp:TextBox>
so how should i modify the following JQUERY, to reflect the input boxes to textboxes replacement?
var $usr = $this.find('input[name=openid_username]');
var $id = $this.find('input[name=openid_identifier]');
Upvotes: 5
Views: 30195
Reputation: 21971
I would go with the following to achieve that:
var $usr = $("input[id$='openid_username']");
var $id = $("input[id$='openid_identifier']");
Upvotes: 0
Reputation: 107616
If you want the exact ID of your controls, you can do this:
var $usr = $this.find('#<%= openid_username.ClientID %>');
var $id = $this.find('#<%= openid_identifier.ClientID %>');
Of course, this is assuming your JS isn't in an external file.
Upvotes: 3
Reputation: 1457
I'm not sure but if ID translates into the elements ID attribute (i.e turns into <input type="text" id="openid_username">
in the aspx generated html, I would go with:
var $usr = $("#openid_username");
Upvotes: 1
Reputation: 70528
var $usr=$("#openid_username");
should work or try
var $usr = $('[id*=openid_username]');
Upvotes: 2
Reputation: 29774
var $usr = $this.find('#openid_username');
var $id = $this.find('#openid_identifier');
Upvotes: 0
Reputation: 532725
I would use the "ends with" option on the attribute selector in case the name is mangled by the control being in a container. Note the $=
instead of =
.
var $usr = $this.find('input[name$=openid_username]');
var $id = $this.find('input[name$=openid_identifier]');
Upvotes: 8