From ASP migratory to ASP+- - processing conversation is variable
Tuesday, March 03, 2009 by rain
===Affirm the user is inputted===
code rescripts the page that the part with the largest workload depends on those getting an user to input,The user inputs these information to become EVille member in order to register.The page that one calls Signup.asp,With will let an user input their important information,Existing member also but this updates record information.Before was not being changed,The data of form submits the page that makes Cookie.asp to through HTTP Post means.The data that this page can confirm form is medium,If be put in the mistake,Guide the user answer Signup.asp to increase wrong number in Query String at the same time.Then statement of a Select Case is met have the output that is based on wrong signal transition.The mistake that we check includes:
* did not input user name
* did not input a password
Password of * and password affirm not agree with
Name of user of * already existed in the database
is passed all input region (Field) changeover accuses into the server,Add RequiredFieldValidators next,The mistake that head of OK and relaxed processing may produce twice.The server after RequiredFieldValidator simply affirms classics ControlToValidate region is differentiated simply accuses in the input is worth:
%26lt;Tr%26gt;
%26lt;Td Valign= %26quot;top%26quot; %26gt;
%26lt;Asp:REquiredFieldValidator Runat=server
ControlToValidate = "txtUserName "
Display = "static "
ErrorMessage= "%26lt;B%26gt;*%26lt;/ B%26gt; %26quot;
ForeColor = %26quot;#CC3300%26quot; /%26gt;
%26lt;/ Td%26gt;
%26lt;Td Valign=top%26gt;User Name:%26amp;Lt; /td%26gt;
%26lt;Td Valign=top%26gt;
%26lt;Asp:TExtBox Id= %26quot;txtUserName%26quot; Size=25 Runat=server /%26gt;%26lt;/ Td%26gt;
%26lt;/ Tr%26gt;
this kind of plan is so simple down to we decide to be in add RequiredFieldValidator to all form to input inside the country.In ASP,We can use function of a VBScript to examine normally the input is worth,And we need what we want to affirm to add RequiredFieldValidator every only now accuse in go.
The comparison that affirms as to password and password,The CompareValidator that we can use ASP+ .Should accuse allow us to install ControlToValidate,ControlToCompare and Operator attribute (be in this exemple be equal to date,Namely 'Equal' ) .Two when be appointed accuse with Operator (namely operator) attribute is compared each other.With traditional If. . .Then statement photograph is compared,This kind of method wants apparently simple,Quick:
%26lt;Asp:COmpareValidator Runat=server
ControlToValidate = "txtConfirm "
ControlToCompare = "txtPassword "
Type = "String "
Operator = "Equal "
Display = "dynamic "
ErrorMessage= "%26lt;B%26gt;*%26lt;/ B%26gt; %26quot;
ForeColor = %26quot;#CC3300%26quot; /%26gt;
is based on different browser,The JavaScript test and verify that ASP+ Validator accuses a can corresponding executive client to carry (be aimed at IE4.0 above version) ,Perhaps carry out a server to carry test and verify (in the light of other circumstance) .No matter test and verify is how carry out,The test and verify that the server carries is indispensable (carry in order to prevent the fellow of certain archness in the client pattern plays on test and verify) .
was turn for the last mistake now.If refer user name has existed,This is about to beg little page alter.So far,We had used the server that can carry out server end and client to carry code of test and verify to accuse finished all ASP+ test and verify.As to finally this mistake,We should offer a few servers that define oneself to carry test and verify,Whether did because we need to visit a database,the user name that is asked in order to understand already exist.We can use ASP+ CustomValidator to accuse will solve this one problem.