Make an input interface today. There is a need to select a different one based on a DropDownList. Different Input interfaces are displayed in the following sections. If you place the RESPONSE event on the server, you must frequently click the page. You just want to put it in the customer to display and hide the corresponding input interface.
It can also be implemented on the server side Using ajax without refreshing the page. But I think there are more direct and simpler methods that can be implemented with a js event.
However, the DropDownList does not include Button and other controls provide some front-end events such as "OnClientClick", only server events.
Think of it, all the C # Page code will eventually generate HTML, and js events will eventually be carried in the browser, based on Html. If the HTML control generated by the server control has any js events, we should be able to add corresponding events to it in aspx.
The Htm generated by DropDownList is an element <Select> with an onchange event, so we can also add an onchange () event to DropDownList. We usually use this method, in the Page_Load event of the background file, add an onchange () event to the DropDownList with the id of ddlExamType:
DdlExamType. Attributes. Add ("onchange", "SelecteChanged (" + this. ddlExamType. ClientID ")");
Front-end js function: SelecteChanged ()
<Script language = "javascript">
Function selectChange (objID ){
Var ddlExamType = document. getElementById (objID );
If (bool ){
......
}
Else {
......
}
}
</Script>
Summary: The C # server-side control adds Attributes. Add () to the control by generating js events of the corresponding control When html is generated.