How could I call a server-side function from the client side, which returned results and use that data from the client side?
client-side code:
html:
<input type="button" value="Search" onclick="codeAddress();"</input>
javascript:
function codeAddress() {
var variable1 = "medicina"
//llamo a la funcion GetData //
//guardo variables cada campo que devuelve la funcion GetData
//...sigo con el codigo
}
server-side code:
Private Function GetData(variable1 As String) As DataTable
Dim conString As String =ConfigurationManager.ConnectionStrings("constr").ConnectionString
Dim cmd As New SqlCommand("select * from location where especialidad =@variable1)
Using con As New SqlConnection(conString)
Using sda As New SqlDataAdapter()
cmd.Connection = con
sda.SelectCommand = cmd
Using dt As New DataTable()
sda.Fill(dt)
Return dt
End Using
End Using
End Using
End Function