C # operation when receiving user input password to confirm

Source: Internet
Author: User

First create a new original form, as follows:

usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;namespacewindowsformsapplication11{ Public Partial classForm1:form { PublicForm1 () {InitializeComponent (); }        Private voidTssave_click (Objectsender, EventArgs e) {            if(RDB02. Checked) {frmpwd F=Newfrmpwd (); F.formclosed+=NewFormclosedeventhandler (f_formclosed);//Event NotificationF.showdialog (); }            Else{test (); }                    }        voidTest () {MessageBox.Show ("Test"); }               voidF_formclosed (Objectsender, Formclosedeventargs e) {            if(Sender asFRMPWD). Ispass)//Ispass is the defined global variable in the form that receives the password input, and sender is the parameter that triggers the event.{test (); }            Else{MessageBox.Show ("Password Error"); }        }    }}

Forms that the password receives:

usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;namespacewindowsformsapplication11{ Public Partial classFrmpwd:form { Public BOOLIspass =false;//If the password is correct, the assignment is true and the default is False         Publicfrmpwd () {InitializeComponent (); }        Private voidButton1_Click (Objectsender, EventArgs e) {            stringStrpwd = This. TextBox1.Text.Trim (); if(Strpwd = ="12345") {Ispass=true; }             This.            Hide ();  This.        Close (); }    }}

The following conditions are required to verify the password:

You do not need to verify the password as follows, directly execute the corresponding function:

C # operation when receiving user input password to confirm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.