Click here to Skip to main content
15,905,232 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i just want to edit the set mask property of a masktextbox in c# which takes only alphabets and numbers and mask it to ******
means i want a masktextbox to show alphabets and numbers as (star or astreik) *
note:- i am making a password field as masked textbgox

help please
thanks in advance
Posted

 
Share this answer
 
u have their no need to use masked edit for this..instead of this you can use filter textbox extender

see example

ASP.NET
<div>
        <asp:scriptmanager id="ScriptManager1" runat="server" >
        </asp:scriptmanager>
        <asp:textbox id="TextBox1" runat="server" textmode="Password" xmlns:asp="#unknown"></asp:textbox>
        <asp:filteredtextboxextender id="TextBox1_FilteredTextBoxExtender">
            runat="server" Enabled="True" TargetControlID="TextBox1" 
            ValidChars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789">
        </asp:filteredtextboxextender>
    </div>


in the above example i have used ajax filtertexbox extender to filer the value as u want..
now your problem is solve


Note-

1. Change the Textbox textmode to Password
2. set the Filter type property of filter extender to custom as i have done..

if any queries reply

thanks
 
Share this answer
 
v2
Comments
shaikh-adil 28-Sep-12 8:33am    
i want code for windows form
: (
wings_ 29-Sep-12 0:28am    
i have already told u change it according to your requirement...
shaikh-adil 30-Sep-12 3:23am    
thanks i have done that
wings_ 1-Oct-12 0:20am    
so accept my answer so my reputation become better and in future i will help u and others
thanks u
shaikh-adil 1-Oct-12 0:42am    
i need i username
which will be minimum of 4 charecters and maximum of 15 chracters
which will allow hifen and underscore and dot in the middle but not in starting and ending of username
(which will not allow symbols except hifen and underscore and dot)
should disallow
-aquib
_aquib
.aquibxyz
aquib.
aquibxyz--qureshi
aquib__xyzqureshi
aquibqureshi-
aquib..qureshi
aquib_ // means no symbols will be there at end
and username should not be numbers it should be mixing of numbers and alphabets or it should be only alphabets
hope this will be understoo

Reply
C#
<asp:RegularExpressionValidator 
ID="validator1" 
ControlToValidate="txt1"
ValidationExpression="XXX" 
Text = "Input Not Valid"
runat="server" />


XXX = ^(\w*)$
that matches char (with accent too), numbers and the underscore

XXX = ^(a-zA-Z0-9)*$
that matches char (with no accent), numbers

Note :
XXX = ^(a-zA-Z0-9){m,n}$

m = minimum lenght
n = maximum lenght
 
Share this answer
 
v3
Comments
shaikh-adil 28-Sep-12 8:32am    
i am using a windows form here.
Not the asp.net page
: (
nrgjack 28-Sep-12 8:36am    
well i think that the regex can be used server side also in windows forms..

take a look here Adding Regular Expression Validation[^]
shaikh-adil 30-Sep-12 3:22am    
thanks buddy
+5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900