开发者

Form's input element name in ASP .NET

开发者 https://www.devze.com 2023-02-06 03:18 出处:网络
I\'m using JQuery plugin that operates on name attributes of form elements. I know that I can access id attribute value by using:

I'm using JQuery plugin that operates on name attributes of form elements. I know that I can access id attribute value by using:

"<%= myControl.ClientID %>"

What开发者_JAVA百科 about name attribute? In html source I see that name & id differ 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 control was on Page. But now, when I placed it inside user control, id and name differ:

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

So instead of using _FullNameTextbox.ClientID I have to access name attribute value


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

"<%= myControl.UniqueID %>"
0

精彩评论

暂无评论...
验证码 换一张
取 消