ASP. NET uses background code to add client-side JS methods to the server control

Source: Internet
Author: User

A simple record of this method: ASP. NET uses the backgroundCodeAdd client-side JS methods to the server control

The front-end code is as follows:

<% @ Page Language = "  C #  " Autoeventwireup = "  True  " Codebehind = "  Webform1.aspx. CS  " Inherits = "  Webapplication1.webform1  " %> <! Doctype HTML> <HTML xmlns ="  Http://www.w3.org/1999/xhtml  " > <Head runat = "  Server  " > <Title> </title> <SCRIPT src = "  Scripts/jquery-1.9.0.min.js  " > </SCRIPT>  "  Form1  " Runat = "  Server " > <Div> <asp: radiobutton id = "  Radiobutton1  " Runat = "  Server  " Groupname = "  Ericsun  " /> <Asp: textbox id = "  Textbox1  " Runat = "  Server " > </ASP: textbox> <br/> <asp: radiobutton id = "  Radiobutton2  " Runat = "  Server  " Groupname = "  Ericsun  " /> </Div> </form> </body>  "  Text/JavaScript  " >Function radiobtnonclick (OBJ) {$ (  "  # <% = Textbox1.clientid %>  " ). ATTR ( '  Disabled  ' , '  Disabled  '  );} </SCRIPT>

Background code:

 Using  System;  Using System. Collections. Generic;  Using  System. LINQ;  Using  System. Web;  Using  System. Web. UI;  Using  System. Web. UI. webcontrols;  Namespace  Webapplication1 {  Public   Partial   Class  Webform1: system. Web. UI. Page { Protected   Void Page_load ( Object  Sender, eventargs e ){  This . Radiobutton1.inputattributes. Add ( "  Onclick  " , "  Radiobtnonclick (this );  "  );  This . Radiobutton2.inputattributes. Add ( " Onclick  " , "  Radiobtnonclick (this );  "  );}}} 

....

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.