Javascript中的级联下拉列表,无法在CodeBehind中获取它们

Javascript中的级联下拉列表,无法在CodeBehind中获取它们,javascript,c#,asp.net,Javascript,C#,Asp.net,我有一个Javascript代码用于级联下拉列表,但问题是我无法访问C web中代码隐藏中的数据 这是我的javascript代码: 我在aspx中有代码: 如何访问下拉列表的动态值 何时要访问数据?单击按钮或下拉更改?@nichu09单击按钮如果您正在对代码隐藏进行ajax调用,则无法访问下拉值。您必须从客户端传递该值。正常按钮单击事件使用您的代码工作,没有任何问题。@nichu09我不知道如何进行ajax调用。 function CollegeDepartment() { var s

我有一个Javascript代码用于级联下拉列表,但问题是我无法访问C web中代码隐藏中的数据

这是我的javascript代码:

我在aspx中有代码:


如何访问下拉列表的动态值

何时要访问数据?单击按钮或下拉更改?@nichu09单击按钮如果您正在对代码隐藏进行ajax调用,则无法访问下拉值。您必须从客户端传递该值。正常按钮单击事件使用您的代码工作,没有任何问题。@nichu09我不知道如何进行ajax调用。
function CollegeDepartment() {
    var s1 = document.getElementById("college");
    var s2 = document.getElementById("department");
    s2.innerHTML = "";
    if (s1.value == "College of Engineering") {
        var optionArray = ["Civil Engineering", "Computer Engineering", "Electrical Engineering", "Electronics and Communication Engineering", "Industrial Engineering", "Mechanical Engineering"];
    } else if (s1.value == "CAS") {
        var optionArray = ["Political Science", "Mascomm", "Liacomm"];
    } else if (s1.value == "Commerce") {
        var optionArray = ["Business Ad", "Hotel Management", "Tourism"];
    } else if (s1.value == "Education") {
        var optionArray = ["SPED"];
    } else if (s1.value == "CICCT") {
        var optionArray = ["Computer Science", "Information Technology"];
    }

    for (var option in optionArray) {
        var newOption = document.createElement("option");
        newOption.value = optionArray[option];
        newOption.innerHTML = optionArray[option];
        s2.options.add(newOption);
    }
};
<div class="form-group">
  <select class="form-control" name="college" id="college" runat="server" oninput="CollegeDepartment()" style="width:300px;">
    <option selected>Select College</option>
    <option value="College of Engineering">College of Engineering</option>
    <option value="CAS">Colpxlege of Arts and Science</option>
    <option value="Commerce">College of Commerce</option>
    <option value="Education">College of Education</option>
    <option value="CICCT">CICCT</option>
  </select>
</div>

<div class="form-group">
  <select id="department" name="department" class="form-control" runat="server" placeholder="Department" style="width:300px;">
    <option value="Department" selected>Select Department</option>
  </select>
</div>