In fact, sometimes dual verification is required between the client and the server. Why? Biguo said that in the text box of a user name, we can only enter letters and numbers through JS verification on the client, and there cannot be special characters! Normally, there is no problem, but there is always a shame to find ways to "Destroy". At this time, we need to perform a dual verification! To put it bluntly, it means that both the server and the client are verified!
For example, a button has The onclick event and onclientclick attributes. The former is generally a server-side click event! The latter is the client click event!
Let's do a test! Add the following code on the default. aspx page!
<Script language = "JavaScript" type = "text/JavaScript">
Function buttonclick (){
Alert ("I Am a client Click Event ");
Return false;
}
</SCRIPT>
Page code:
<Form ID = "form1" runat = "server">
<Div>
<Asp: button id = "button1" runat = "server" text = "some buttons are server-side controls. The onclientclick event is used by default. Please disable the JS function of the browser to experience it"
Onclick = "button#click" onclientclick = "Return buttonclick ();"/>
<Asp: Label id = "label1" runat = "server" text = ""> </ASP: Label>
</Div>
</Form>
CS file code:
Protected void button#click (Object sender, eventargs E)
{
This. label1.text = "I Am a server Click Event ";
}
Let's see what the effect is? You may find that only the code in JS is popped up! That's right. This is exactly what we want. Use return false to "Block" server verification! What are the benefits? You don't need to refresh the page!
You disabled the Script Function of the browser. Try again to see what the effect is?
By re-checking, the user's illegal input can be ensured. This is what we want!