asp.net动态生成的button控件的事件响应函数如何绑定为定义好的一个javascript方法。
比如定义的Button为Buttonbtn=newButton();然后是添加btn的onclientclick事件么,具体怎么写?...
比如定义的Button为Button btn=new Button();然后是添加btn的onclientclick事件么,具体怎么写?
展开
展开全部
Tbutton = New Button
name = "name" & i
name = connclass.GetINI("list", name, "", filepath)
If name Is Nothing Then
name = "空值"
End If
Tbutton.Name = name & i '防止有重复的ID名出现
Tbutton.Text = name
Tbutton.Width = 100
Tbutton.Height = 35
Tbutton.Tag = i
If i <= 5 Then
x1 = 0
ElseIf i <= 10 Then
x1 = 1
ElseIf i <= 15 Then
x1 = 2
ElseIf i <= 20 Then
x1 = 3
ElseIf i <= 25 Then
x1 = 4
Else
x1 = 5
End If
y1 = i - x1 * 5
Tbutton.Top = 10 + x1 * (Tbutton.Height + 5)
Tbutton.Left = 8 + (y1 - 1) * (Tbutton.Width + 2)
'PANEL上增加控件
Me.PanelButtonZone.Controls.Add(Tbutton)
'自动给最后一个控件加单击事件,原因不明
If i <> buttoncounter Then
AddHandler Tbutton.Click, AddressOf Me.Tbutton_click
End If
Next
End Sub
'按钮响应事件
Private Sub Tbutton_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tbutton.Click
'''''''''''
End Sub
name = "name" & i
name = connclass.GetINI("list", name, "", filepath)
If name Is Nothing Then
name = "空值"
End If
Tbutton.Name = name & i '防止有重复的ID名出现
Tbutton.Text = name
Tbutton.Width = 100
Tbutton.Height = 35
Tbutton.Tag = i
If i <= 5 Then
x1 = 0
ElseIf i <= 10 Then
x1 = 1
ElseIf i <= 15 Then
x1 = 2
ElseIf i <= 20 Then
x1 = 3
ElseIf i <= 25 Then
x1 = 4
Else
x1 = 5
End If
y1 = i - x1 * 5
Tbutton.Top = 10 + x1 * (Tbutton.Height + 5)
Tbutton.Left = 8 + (y1 - 1) * (Tbutton.Width + 2)
'PANEL上增加控件
Me.PanelButtonZone.Controls.Add(Tbutton)
'自动给最后一个控件加单击事件,原因不明
If i <> buttoncounter Then
AddHandler Tbutton.Click, AddressOf Me.Tbutton_click
End If
Next
End Sub
'按钮响应事件
Private Sub Tbutton_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tbutton.Click
'''''''''''
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询