Small details of OnClick in work experience; onclick in work experience
Today I encountered a problem about OnClientClick and OnClick,Let's take a look at the differences in the following code:
<Asp: Button ID = "btnQuery" runat = "server" Text = "query (Q)" AccessKey = "Q" OnClientClick = "btnQuery (); "OnClick =" btnQuery_Click "CssClass =" nButton "/>
<Asp: Button ID = "btnQuery" runat = "server" Text = "query (Q)" AccessKey = "Q" OnClientClick = "return btnQuery (); "OnClick =" btnQuery_Click "CssClass =" nButton "/>
One return is added to the OnClientClick method.
OnClientClick = "btnQuery ();" This will certainly execute the btnQuery method. However, no matter whether the return value is true or false, it will jump to the OnClick event. That is to say, when our judgment is incorrect, will also go to the cs class to execute the background code, equivalentThe OnClientClick event does not play its role.
If the OnClientClick event is defined, The OnClick event will be executed only when the return true event is returned. It was actually the reason for the return of a word, and it took me an entire hour.
During verification and judgment, some verifications can be determined on the page, without the need to go to the cs class in the background, let's just talk about the js judgment that contains special characters in the text box.
In fact, it is very easy to write in cs. The Code is as follows:
this.TextBox1.Text.Trim().Contains("$")
But we need to put it in front-end js, but it won't work. Let's take a look at the following code:
txtNum.value.trim().indexOf('$')>= 0
Well, this is a little bit of knowledge sharing, little knowledge, great wisdom!
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.