Cadecading下拉列表不起作用,当我在IIS中发布时,但在Visual Studio 2015工作正常,首先使用ASP.NET MVC代码 [英] Cadecading dropdown list not working , , when I publish in IIS , but in visual studio 2015 working fine , by using ASP.NET MVC code first

查看:58
本文介绍了Cadecading下拉列表不起作用,当我在IIS中发布时,但在Visual Studio 2015工作正常,首先使用ASP.NET MVC代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在mvc控制器中创建了脚本调用函数,它在visual studio中运行良好,但是当我转换到IIS网站时,所有网站都运行良好的其他casecading下拉列表,,,



我的代码(



=========================== ==============================



功能





i create the script call function in mvc controller , it's working good in visual studio, but when i converted to IIS website , all website working good else casecading dropdownlist ,,,

my code (

=========================================================

function


public ActionResult FillDept(string level)
  {

         var depart = db.Departments.Where(c => c.LevelId == level);
             return Json(depart, JsonRequestBehavior.AllowGet);

  }













脚本在html视图中









script in html view

<script>

    function FillDept() {
        var levelId = $('#Level').val();
        $.ajax({
            url: '/Trainees/FillDept',
            type: "GET",
            dataType: "JSON",
            data: { Level: levelId },
            success: function (depart) {
                $("#Department").html(""); // clear before appending new list
                $.each(depart, function (i, department) {
                    $("#Department").append(
                        $('<option></option>').val(department.DeptId).html(department.DeptName))


                });
            }
        });
    }
</script>















dropdwonlist












dropdwonlist


 @Html.LabelFor(m => m.Level, new { @class = "control-label col-md-1" })
 <div class="col-md-3 jumbotron">
     @Html.DropDownListFor(m => m.Level,
        new SelectList(ViewBag.LevelList, "LevelId", "LevelName"),
        "level",
       new { @class = "form-control", @onchange = "FillDept()" })
     @Html.ValidationMessageFor(m => m.Level, "", new { @class = "text-danger" })

 </div>



 @Html.LabelFor(m => m.Department, new { @class = "control-label col-md-1" })
 <div class="col-md-3 jumbotron">
     @Html.DropDownListFor(m => m.Department,
new SelectList(Enumerable.Empty<SelectListItem>(), "DeptId", "DeptName"),
       "department", new { @class = "form-control" })
     @Html.ValidationMessageFor(m => m.Department, "", new { @class = "text-danger" })

 </div>













我尝试过的事情:



你好,我需要帮忙...





)

What I have tried:

Hi there , i need to help please ..

asp.net MVC code first

推荐答案

('#Level')。val ();
('#Level').val();


.ajax({
url:'/ Trainees / FillDept',
type:GET,
dataType:JSON ,
数据:{Level:levelId},
成功:函数(离开){
.ajax({ url: '/Trainees/FillDept', type: "GET", dataType: "JSON", data: { Level: levelId }, success: function (depart) {


(#Department)。html(); //在添加新列表之前清除
("#Department").html(""); // clear before appending new list


这篇关于Cadecading下拉列表不起作用,当我在IIS中发布时,但在Visual Studio 2015工作正常,首先使用ASP.NET MVC代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆