How to add JS methods to Web controls

Source: Internet
Author: User
In normal development, JS methods are often used in Web controls. Next I will introduce the usage.
(1) Add JS functions to the button. Lbndelete. attributes ("onclick") = "Return delconfirm ();"

(2) Add JS functions to textbox. Txtmenucode. attributes ("onblur") = "menucodecheck ('txtmenucode ');"

(3) add JS functions to radiobutton. Rbtpack. attributes ("onclick") = "moneycont (2 );"

(4) add JS functions to dropdownlist. Ddtkbmncd1.attributes ("onchange") = "lickbumenchange (1 )"

(5) add JS functions to the DataGrid and gridview. 1 private sub dgmenu_itemdatabound (byval sender as object, byval e as system. Web. UI. webcontrols. datagriditemeventargs) handles dgmenu. itemdatabound
2 'zookeeper registration name'
3 const methodname as string = "dgmenu_itemdatabound"
4 try
5 if E. Item. itemtype = listitemtype. item or _
6 E. Item. itemtype = listitemtype. alternatingitem then
7 selindex = selindex + 1
8. The Comment comment indicates the comment in the middle and the reverse comment indicates the comment in the selection.
9 E. Item. Attributes. Add ("onmouseover", "tdonover (this );")
10 E. Item. Attributes. Add ("onmouseout", "tdonout (this );")
11' rows were too large, too many rows were too large.
12 E. item. attributes. add ("onclick", "setmenucode (" + "'" + CSTR (E. item. cells (1 ). text) + "'," + _
13 "'" + CSTR (selindex) + "'" + ")")
14 end if
15 catch ex as exception
16' you want to determine whether there are two possible causes for this problem.
17 dim COMEX as poscomexception = new poscomexception (methodname, poscom_log_error, "", ", ex)
18 'common features
19 commonerrormanage (COMEX)
20 end try
21 End sub

The above is a common method to add js to Web controls in the background.

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.