OnClick and OnClientClick really took some time to figure out for cainiao. OnClientClick is run on the client. OnClick will run postback on the server ). However, there are execution time and conditions. Time Sequence: When a button is clicked on a webpage, The OnClientClick of the client is triggered first, and then the OnClick line is merged. Condition: OnClick will be executed only when OnClientClick returns true. By default, the OnClientClick function returns true if the OnClientClick function does not return a value. Therefore, the OnClick function can be executed smoothly. However, there are also some values that do not allow OnClick execution in some cases. For example, you can use Javascript to perform the first-level verification or basic checks. If the conditions are not met, OnClick is not triggered to return to the server to continue the logic.
In this case, the response of OnClientClick must be artificially set to false. The procedure is simple. Defines a Javascript or vbscript function that returns true or false values based on the detection conditions. Then it is called in OnClientClient. The method is OnClientClick = "return fun (the Javascript or vbscript function you defined);" in this way, OnClick is triggered only when the condition is met. If the condition is not met, OnClick is not triggered.
The younger brother was not long before he started writing asp.net. It is a dish in the dish. So I am not familiar with many things. Here I will share my daily work experience. Thank you for your advice.