I have one TextBox for Password and i want to set character for password, so which property can be used in asp.net?
<asp:TextBox TextMode="Password" runat="server" />
I have one TextBox for Password and i want to set character for password, so which property can be used in asp.net?
<asp:TextBox TextMode="Password" runat="server" />
PasswordChar
property is under this namespace, System.Windows.Forms. It is not available for asp .net web applications.
You could try JavaScript
to change it into other characters such as "*" or "@".
You can see the following example to do so:
<script type="text/javascript">
function onTextChange(obj)
{
document.getElementById('hdnActualTextValue').value = obj.value;
obj.value = '';
for(int i=0; i<obj.value.length;i++)
{
obj.value +='*';//OR ANY OTHER CHARACTER OF YOUR CHOICE
}
}
</script>
<asp:TextBox ID="txtValue" runat="server" onblur="javascript:onTextChange(this);"
onkeyup="javascript:onTextChange(this);" onkeypress="javascript:onTextChange(this);"></asp:TextBox>
<asp:HiddenField ID="hdnActualTextValue" runat="server" />
OR maybe you could use input
in HTML.
<label>PW: <input type="password"></label>
I think if you are using the Web Forms then in that the Password Characters are fixed. You can not change unless you use Javascript to change some behavior at run time
When we use WebForms in that PasswordCharacters are set by default.
Check out this link. You can get some Idea what I am telling you.
Simply use TextMode
property in asp
<asp:TextBox ID="txtValue" runat="server" TextMode ="Password"> </asp:TextBox>