1. Button front and back-end events
<Asp: button id = "button1" runat = "server" onclick = "button#click" text = "button"
Onclientclick = "alert ('room-side verification, blocking server-side submissions '); Return false;"/>
2. Register related events: onblur, onclick, onchange
This. textbox1.attributes. Add ("onchange ",
"Alert ('data changed, check whether the input meets the rule ');");
3. Registration attributes:
This. textbox1.attributes. Add ("readonly", "true ");
4. Introduce JS files
Front-end HTML page:
<SCRIPT type = "text/JavaScript" src = "jscript. js" Language = "JavaScript"> </SCRIPT>
<SCRIPT type = "text/JavaScript" Language = "JavaScript">
Function fn_name ()
{
Alert ("JS ");
}
</SCRIPT>
Backend CS page:
This. registerclientscriptblock ("jsfile ",
"<SCRIPT type = 'text/JavaScript 'src = 'jscript. js' Language = 'javascript '> </SCRIPT> ");
5. When you click the button, the related column is not empty.
Function checkempty (txtobj, msgshow)
{
If (txtobj. value = "")
{
Alert (msgshow );
Return false;
}
}
<Asp: button id = "button1" runat = "server" onclick = "button#click" text = "button"
Onclientclick = "Return checkempty (textbox1, 'textbox1 cannot be blank ')"/>
6.
// Select whether to use chcekbox
// Control whether the textbox is input.
Function chktextbox (chkobj, txtobj)
{
If (chkobj. Checked = true)
{
Txtobj. value = "";
Txtobj. readonly = false;
Txtobj. Focus ();
}
If (chkobj. Checked = false)
{
Txtobj. value = "";
Txtobj. readonly = true;
}
}
<Input id = "checkbox1" type = "checkbox" onclick = "chktextbox (checkbox1, textbox1)"/>
... To be continued