为什么我用vb.net动态的给按钮加上了事件,但是不管用,谁能帮帮我。。。
Dim btnOK As UI.WebControls.ButtonbtnOK = New UI.WebControls.Button
btnOK.Text = "增加"
btnOK.ID = "btn" + i.ToString
AddHandler btnOK.Click, AddressOf add_student
Me.form1.Controls.Add(btnOK)
//这个是增加按钮点击的方法
Private Sub add_student(ByVal sender As Object, ByVal e As System.EventArgs)
Dim sql As String
sql = "insert into a (name,易做图,num,postdate) values("
Dim btn As UI.WebControls.Button = sender
If btn.ID > 0 Then
Dim panel As UI.WebControls.Panel = sender
For Each ctr As Control In panel.Controls
For Each ctr1 As Control In ctr.Controls
sql += "'" & ctr1.Text & "',"
Next
Next
End If
Dim btnid As String = ViewState("btid")
End Sub
为什么增加按钮点半天没反应呢。 --------------------编程问答-------------------- ?UI.WebControls.Button????
Private Sub add_student(ByVal sender As Object, ByVal e As System.EventArgs)是winform的按钮单击事件吧,网页的不懂 --------------------编程问答-------------------- 我把你的add_student 里面改成Response.Write后运行显示事件是激活的有效的
另外btnOK 里面的btnOK.ID = "btn" + i.ToString我也去掉了
你自己在调试下看看
补充:.NET技术 , VB.NET