Vb.net按钮自动按下

时间:2011-12-11 09:08:42

标签: asp.net vb.net

页面加载时,是否有任何方法可以自动按下网页上的按钮?

我在按钮上有以下代码来制作网格视图行

 Dim nos() As Integer = New Integer((Convert.ToInt32(10)) - 1) {}
        Dim i As Integer = 0
        Do While (i < nos.Length)
            nos(i) = (i + 1)
            i = (i + 1)
        Loop
        GridView1.DataSource = nos
        GridView1.DataBind()
        btnInsert.Visible = True
        btnInsert.Enabled = True
        GridView1.Focus()

我还将此代码粘贴到页面加载事件上,但是当页面加载时,它不会将文本框值插入数据库,只有从按钮执行此代码时才会获取值。这就是为什么我要求在页面加载时自动按下按钮

1 个答案:

答案 0 :(得分:0)

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
a()
End Sub


Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
a()
End Sub


Sub a()
Dim nos() As Integer = New Integer((Convert.ToInt32(10)) - 1) {}
    Dim i As Integer = 0
    Do While (i < nos.Length)
        nos(i) = (i + 1)
        i = (i + 1)
    Loop
    GridView1.DataSource = nos
    GridView1.DataBind()
    btnInsert.Visible = True
    btnInsert.Enabled = True
    GridView1.Focus()
End Sub