用户在c#中更改登录表单的密码 [英] changing the password by user for login form in c#

查看:72
本文介绍了用户在c#中更改登录表单的密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的程序中有一个登录表单但是,我想要另一个表单,用户可以更改他的密码。它有三个texbox和一个按钮。在第一个文本框用户写入旧密码,在第二个写入新密码,并在第三个写入新密码确认。当他点击按钮时密码会改变,如果输入错误,会显示一些错误。

请帮帮我:confused:

非常感谢

I have a login form in my program but, i want to have another form that user can change his password. it has three texboxes and one button. at the first textbox user write the old password,at the second write new password and at the third write new password confirm. when he click on the button password would change and if he type wrong, shows some errors.
please help me :confused:
thanks alot

推荐答案

下面是示例代码



Here is sample code to do that

//Assumed you have saved your old password in database or someplace else(like a file or something) and it's retrieved and stored in var called OldPassword 


if(txtOldPassword.Text == OldPassword)
{
    if(txtNewPassword.Text == txtReEnterNewPassword.Text)
    {
         //Save the new password to database or where ever you want
    }
    else
    {
         //Show error mes saying new password does not match.clear the         text box and ask user to re-enter password.
    }
}
else
{
    //give the error mes saying the password provided is wrong and try again
}  


如果您是通过从工具箱添加登录组使用常规流程创建的,那么请查看 MSDN [ ^ ]并向下滚动到让用户更改密码
If you have created it using the normal process by adding a Login group from the toolbox, then look at MSDN[^] and scroll down to "Letting Users Change Their Password"


这篇关于用户在c#中更改登录表单的密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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