On the server side, you can also use Ajax to implement, do not brush the page. But I think there is a more direct and simple way to use a JS event is achievable.
However, the DropDownList button and other controls provide some things like "onclientclick" foreground events, only server-side events.
Think of all the C # page code that ultimately generates HTML,JS events that are ultimately shipped in the browser, based on HTML. The HTML control that the server-side control eventually generates has a JS event, and we should be able to add the corresponding event to it in ASPX.
DropDownList generated htm is the element <Select> is onchange event, so we can also give DropDownList add onchange () event, we usually use the method, in the background file Page_Load event, add the onchange () event to the DropDownList with ID Ddlexamtype:
DDLEXAMTYPE.ATTRIBUTES.ADD ("onchange", "selectechanged" (' +this.ddlexamtype.clientid ")");
The JS function defined by the foreground: selectechanged ()
Copy Code code as follows:
<script language= "JavaScript" >
function Selectchange (ObjID) {
var ddlexamtype = document.getElementById (ObjID);
if (bool) {
......
}
else {
......
}
}
</script>
Summary: C # server-side control, when generating HTML corresponding control what JS event, we can add to the control Attributes.Add ().