更改TextMode属性 [英] change the TextMode property

查看:139
本文介绍了更改TextMode属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何在javascript中更改TextMode asp文本框属性(单行,多行,密码).是否有可能.

I would like to know how to change the TextMode asp textbox property (Singleline,multiline,password)in javascript.Is there any possibility.

推荐答案

尝试一下
Javascript
Try this
Javascript
<script type="text/javascript">
       function test() {
           document.getElementById('<%= txt.ClientID %>').type = 'password';
       }
   </script>



设计部分



Design Part

<asp:TextBox ID="txt"  runat="server" TextMode="SingleLine"></asp:TextBox>
 <div  onclick="test();" >click</div>


这是解决方案,

Here is the solution,

<div>
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
<script type="text/javascript">
    var obj = document.getElementById("TextBox1");
    var newObj = document.createElement(''input'');
    newObj.setAttribute(''type'', ''password'');
    newObj.setAttribute(''id'', obj.getAttribute(''id''));
    newObj.setAttribute(''name'', obj.getAttribute(''name''));
    obj.parentNode.replaceChild(newObj, obj);
    newObj.focus();
</script>



基本思想是用所需的文本模式创建一个新元素,然后用新的替换原来的元素.

希望这会有所帮助.
欢呼



The basic idea is to create a new element with your desired textmode and replace the original with the new one.

Hope this helps.
cheers


http://www.aspsnippets.com/Articles/Display-Watermark-Text-for-ASPNet-TextBox-Password-and-MultiLine-TextArea-using-jQuery-Plugin.aspx[^]

u may get something out of this...
check this


这篇关于更改TextMode属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆