Recently I was working on a Web back-end statistics system. I wanted to use Asp.net (
Code Binding), but found very difficult, some functions are easier to use JavaScript. In many cases, the interaction between C and S and database operations are involved. Javascript is relatively strong on the client control interface, but it is better to operate the database on the server than Asp.net.
The JS function is bound to the Asp.net control:
You can use the control. Attributes. Add (event, function), but I always report an error when I add the oncheckedchanged event to the checkbox.
Access the HTML control in Asp.net:
In one breath, all controls are replaced with HTML, and then runat = server is added to the control so that they can be referenced in Asp.net. Use (findcontrol (Control ID) as HTML control type). properties, such as (this. findcontrol ("ddlmonth") as htmlselect). selectedindex ......
Read the Asp.net variable from the HTML webpage.
In order to be able to read data in Asp.net in JS, we need to ensure that JS of the variable type in Asp.net can be distinguished. In fact, we can find a way to change it to string!
Second, declare the variable as public.
Use variable = "<% # Asp.net variable name %>"; in JS to get the variable value, such as VAR id = "<% # userid %> "; (Public String userid = "zhangsan" in Asp.net ";
We can use a good combination of JS and Asp.net to give full play to our respective strengths and use them in a targeted manner during the development process. We can really handle things!