急!如何用JAVACRIPT实现调用客户端程序
下面这段服务器端程序,如果在客户端用JAVASCRIPT读取
SqlDataReader dr;
string connectionString = ConfigurationManager.ConnectionStrings["Cconnection"].ConnectionString;
SqlConnection connection = new SqlConnection(connectionString);
try
{
connection.Open();
SqlCommand cmd = new SqlCommand("Ownn_ReadCoursesName", connection);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@TeacherID",TeacherID));
dr = cmd.ExecuteReader();
while (dr.Read())
{
this.ListCourseName.Items.Add(new ListItem(dr["CourseName"].ToString(), dr["ID"].ToString()));
}
}
catch (Exception ex)
{
Response.Write("\"" + ex.Message + "\"");
}
finally
{
dr = null;
connection.Close();
}
------解决方案--------------------这段代码直接转成js是不可能了。
不过可以让客户端掉用服务器端代码来实现。
把那段代码加在buttononclick里边
客户端
document.getElementByID("buttonid").click();
------解决方案--------------------<%=%>