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.