WPF Web Based

WPF Examples

WPF

WPF Projects

WPF Project

adplus-dvertising
PasswordBox Control in WPF Web Base
Previous Home Next

The password box control is a special type of TextBox designed to enter passwords. The typed in characters are replaced by asterisks. Since the password box contains a sensible password it does not allow cut, copy, undo and redo commands. The PasswordBox control allows you to hide the characters and limit the number of characters to be typed in the editable area.

Properties:

Password property contains the password in the passwordbox and PasswordChar is the masking character for the password. Following tag create the Password Box control with the masking character as * and maximum password length of 50 characters. The MaxLength property is used to get and set the maximum number of characters you can enter in a PasswordBox.

 <PasswordBox Height="23" Margin="40,74,118,0" Name="PasswordBox1"
 VerticalAlignment="Top" PasswordChar="*" MaxLength="50" />

Events:

PasswordChanged event is main event of the control and is raised when password property has been changed. To handle the event add the PasswordChanged=Password1_OnPasswordChanged in the xaml and write the handler as

protected void Password1_OnPasswordChanged(object sender, RoutedEventArgs e)
{
Console.WriteLine(PasswordBox1.Password);
}

.XAML CODE :

<Page x:Class="WpfBrowserApplication5.Page3"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Page3">
<Grid Background="AliceBlue">
<PasswordBox Height="23" Margin="85,91,0,0" Name="passwordBox1" 
VerticalAlignment="Top" HorizontalAlignment="Left" Width="102" Password="gupta"/>
<TextBox Height="23" Margin="85,56,113,0" Name="textBox1" VerticalAlignment="Top" 
HorizontalAlignment="Left" Width="102" />
<Label Height="23" HorizontalAlignment="Left" Margin="17,56,0,0" Name="label1" 
VerticalAlignment="Top" Width="81">Username</Label>
<Label Height="23" HorizontalAlignment="Left" Margin="17,91,0,0" Name="label2"
 VerticalAlignment="Top" Width="81">Password</Label>
<Button Margin="81,150,144,127" Name="button1" Click="button1_Click">Button</Button>
</Grid>
</Page>
Output :
Previous Home Next
WPF Examples

WPF

WPF

WPF

WPF

WPF

WPF

WPF

WPF