The alternate use of server and client controls is to get the values of each control, either by using C # or JS directly to determine if the condition is met.
Here is the server control as an example, as for the client control needs to write JS code
1, USERBF Public classuserbf{PrivateMydbdatacontext _context; PublicUSERBF () {_context=NewMydbdatacontext (); } Public BOOLSelect (stringUserName,stringUSERPWD)//Verify user name { varquery = _context. Loginuser.where (p=>p.username==username&&p.userpwd==userpwd); returnQuery. Count () >0; } Public BOOLLogin (stringUserID)//Verify that the ID is unique { varquery = _context. Loginuser.where (P = p.userid==UserID); returnQuery. Count () >0; } Public voidInsert (stringUseridstringUsernamestringuserpwd) {Loginuser Data=NewLoginuser (); Data. UserID=userid; Data. UserName=username; Data. Userpwd=userpwd; _context. Loginuser.insertonsubmit (data); _context. SubmitChanges (); }}2, front desk design<form id="Form1"runat="Server"> <div> <center>"Label5"runat="Server"text="User id:"></asp:label> <asp:textbox id="TextBox2"runat="Server"Ontextchanged="textbox2_textchanged"></asp:textbox><input id="Button3"Type="Button"Value="Unique authentication"runat="Server"onserverclick="Button3_serverclick"><br> <asp:label id="Label6"runat="Server"text="User name:"></asp:label> <asp:textbox id="TextBox3"runat="Server"></asp:TextBox><br> <asp:label id="Label7"runat="Server"text="Password:"></asp:label> <asp:textbox id="TextBox4"runat="Server"></asp:TextBox><br> <asp:label id="Label8"runat="Server"text="Confirm Password:"></asp:label><asp:textbox id="TextBox5"runat="Server"></asp:TextBox><br> <asp:button id="Button4"runat="Server"text="Register"Enabled="False"onclick="Button1_Click"/> </center> </div></ from>3, code for background write validation in C #protected voidButton1_Click (Objectsender, EventArgs e)//registration of the server { stringUserID =TextBox2.Text; stringUsername =TextBox3.Text; stringUserpwd =Textbox4.text; stringUserpwdagain =Textbox5.text; if(userid=="") {Response.Write ("<script>alert (' User ID cannot be empty!! ') </script>"); } Else if(username=="") {Response.Write ("<script>alert (' User name cannot be empty!! ') </script>"); } Else if(Userpwd = ="") { Response.Write ( "<script>alert (' user password cannot be empty!! ') </script> "); } Else if(Userpwd! =Userpwdagain) {Response.Write ("<script>alert (' two times the password is not the same, please re-enter!! ') </script>"); } Else { NewUSERBF (). Insert (USERID,USERNAME,USERPWD); Response.Write ("<script>alert (' Registration successful!! ') </script>"); } } protected voidButton3_serverclick (Objectsender, EventArgs e)//Server unique Authentication { if(string. Isnullorwhitespace (TextBox2.Text)) {Response.Write ("<script>alert (' User ID cannot be empty!! ') </script>"); } Else { BOOLisOK =NewUSERBF (). Login (TextBox2.Text); if(isOK) {Response.Write ("<script>alert (' This ID already exists, please change!! ') </script>"); } Else{Response.Write ("<script>alert (' Congratulations you can use!!! ') </script>"); Button4.enabled=true; } } } protected voidTextbox2_textchanged (Objectsender, EventArgs e) {button4.enabled=false; }
:
→ →
→ → →
→ →→ →
webform--Registration Verification