Type the name of the input element in ASP.NET.

I am using a jQuery plugin that works with the name attributes of form elements. I know that I can access the id attribute value using:

"<%= myControl.ClientID %>"

What about the name attribute? In the html source, I see that the name and identifier are different from each other.

Thanks PaweΕ‚

EDIT:

Full code:

  $("form").validate({ rules: { "<%= _FullNameTextbox.ClientID %>": { required: true, minlength: 2 }, "<%= _EmailAddressTextbox.ClientID %>": { required: true, email: true } }, messages: { "<%= _FullNameTextbox.ClientID %>": { required: "Please enter your full name", minlength: "Your name must consist of at least two characters" }, "<%= _EmailAddressTextbox.ClientID %>": { required: "Please enter a valid email address", email: "Please enter a valid email address" } } }); 

It worked fine when the control was on the page. But now that I have placed it inside the user control, id and name are different:

 <input type="text" id="Container__EmailAddressTextbox" name="Container$_EmailAddressTextbox" class="error"> 

So instead of using _FullNameTextbox.ClientID, I need to access the value of the name attribute

+7
source share
1 answer

The UniqueID property of your control will be used as its name attribute on the client side, so you can write:

 "<%= myControl.UniqueID %>" 
+11
source

All Articles