On the Asp.net page, we can use HTML controls and Web controls. Control executableProgramIncluding client programs (JS scripts) and server programs (server programs ). Client JS ProgramEarlierServer-side program execution.
HTML Control
Add the runat = "server" attribute to the HTML form element to the HTML control.
Traditional events of HTML form elements can trigger JS scripts. However, to trigger server events, you must add "server"
For example: onclick = "" triggers JS scripts, onserverclick = "" triggers server programs
Web controls
Web controls are a group of powerful. Net-optimized controls.
Web controls can trigger JS scripts or server programs. Traditional events are mainly used to trigger server programs. To trigger JS programs, you must add "client" to the events"
For example, onclick = "" triggers server programs, and onclientclick triggers JS scripts.
JS scripts and server programs
When we click the button, the JS script will be triggered on the client first, and then the server program will be executed.
Sometimes we need to use JS scripts to determine whether to execute the server program. We need the JS script to return the bool value. If it is true, the server program is executed. If it is false, the server program is not executed.
For example, onclientclick = "javascript: Return mybtn_onclick ();" in the mybtn_onclick () script, we will return true/false.