【发布时间】:2016-10-26 19:34:18
【问题描述】:
当焦点进入 HTML 下拉列表时,我无法调用服务器端 LoadStudent() 方法。
服务器端编码
Imports System.Data.SqlClient
Public Class FeeEntry
Public Sub LoadStudent()
MsgBox("Called")
Using cmd As New SqlCommand("SELECT StudentName FROM Student")
cmd.CommandType = CommandType.Text
cmd.Connection = con
'con.Open()
DropDownList1.DataSource = cmd.ExecuteReader()
DropDownList1.DataTextField = "StudentName"
DropDownList1.DataValueField = "StudentName"
DropDownList1.DataBind()
con.Close()
End Using
End Sub
End Class
HTML 代码
<asp:DropDownList ID = "DropDownList1" runat="server" onfocus="LoadStudent()" CssClass ="form-control">
</asp:DropDownList>
【问题讨论】: