开发者

Watermark asp:Login control Username and Password fields

开发者 https://www.devze.com 2022-12-24 06:44 出处:网络
I\'m trying to watermark the asp:Login controls\' User开发者_如何学Pythonname and Password fields with jQuery, I\'ve tried various ways of referencing the control ID:

I'm trying to watermark the asp:Login controls' User开发者_如何学Pythonname and Password fields with jQuery, I've tried various ways of referencing the control ID:

$('#<%=ClientID.Login1_UserName %>').watermark('watermark', 'Username');

I have tried moving the ClientID, Login1 and UserName around and changing the selectors to and from userscores and periods...

Any ideas?


Good old jQuery selectors ;)

$("input[name*='UserName']").watermark('watermark', 'Username');


$("input[id$='_UserName']:first").watermark('watermark', 'Username');


If you have an

<asp:TextBox ID="Login1_UserName" ... >

then your jquery code needs to look something like this

<script type="text/javascript">
<!--
    $(document).ready(function() {
        $('#<%= Login1_UserName.ClientID %>').watermark('watermark', 'Username');
    }
// -->
</script>

although @Gogster had a very good suggestion as well--to avoid the <% %> tags altogether, which in my opinion is a bit more elegant and no less difficult to understand.

0

精彩评论

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