The first method: Do not use Button in the web control to solve this problem with Button in HTML: Specifically, in: HTML, define such a Button ---------------- --------- --- ---------------------------- then in CodeBehind, use the ServerClick event, namely: private sub mybutton_serverclick (Byval Sender As Object, BYVAL E A System.Eventargs) Handles MyButton.serverClick ..... End Sub --------------------------------- - Note, in CodeBehind, you must also have the following sentence definition buttons sentence protected withevents mybutton as system.Web.ui.htmlControls.htmlinputButton
Here is the test code, you can try it yourself:
Private Sub Page_Load (Byvale AS System.Object, Byval E AS System.Eventargs) Handles MyBase.Load
'Place the user code of the initialization page here
If Not IsPostBack Then Dim conn As New SqlConnection ( "server = localhost; user id = sa; password = ycm119; database = pubs;") Dim dad As New SqlDataAdapter ( "Select * from employee", conn) Dim dst As New DataSet DAD.FILL (DST, "Employee") DataGrid1.datasource = Dst.Tables ("Employee") DataGrid1.Database () end ifend sub
Private sub mybutton_serverclick (byval e AS object, byval e as system.eventargs) Handles mybutton.serverClick data.dataSource = "" DataGrid1.database () end sub ----------------- -------------------------------------------------- ------------------------------------ http://community.9cbs.net/expert/topic / 3344/3344371.xml?temp =.8338129#top second method: write void button1_click (Object sender, system.eventargs e) {// .... response.write ("