0
当焦点进入HTML下拉列表时,我无法调用Server Side LoadStudent()方法。在Html和asp.net中加载服务器端函数onfocus
服务器端的编码
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>
兄弟下拉列表将被填充将按照所选学生课,所以它必须写在onfocus或onblur我不能写在页面加载事件 –
你可以设置一个事件,当你的具体学生选择被更改,将更新DropDownList?假设你的学生在一个单独的列表中,只需设置一个事件来确定它何时发生变化,然后调用LoadStudent()方法。 –