如何从 ASP.NET mvc 中的下拉列表移动到另一个视图

How to move to another view from dropdown list in ASP.NET mvc

我被困在这里一个多星期了。我正在尝试创建一个下拉列表,当用户从下拉列表中单击某个值时,它将重定向到另一个名为 index.js 的视图。所以下面是我的下拉代码。下拉列表中的值是从 SQL 服务器获得的。我该怎么办,我应该在控制器中更改还是在视图中更改?

@Html.DropDownListFor(model => model.Reference, ViewBag.ISharedUI as SelectList, "-- REFERENCE TYPE --")
@Html.ValidationMessageFor(x => x.reftab)

提前致谢。

编辑:

顺便说一下,下面是我的控制器中的代码,用于显示下拉列表的值

   public ActionResult Create()
    {
        List<CommonEntities> ISharedUI = CommonDAL.GetARSharedReference();
        ViewBag.ISharedUI = new SelectList(ISharedUI, "ID", "Description");
        return View("Create");
    }

    //Here here here here here here 
    // POST: ListOfItems/Create
    [HttpPost]
    public ActionResult Create(ListOfItems objListOfItems)
    {
        try
        {
            // TODO: Add insert logic here
            List<CommonEntities> ISharedUI = CommonDAL.GetARSharedReference();
            ViewBag.ISharedUI = new SelectList(ISharedUI, "ID", "Description");


            ListOfItems objListOfItemss = new ListOfItems();
            objListOfItemss = ARSharedDAL.CreateARSharedInsert(objListOfItems);

            return RedirectToAction("Index");
        }
        catch
        {
            List<CommonEntities> ISharedUI = CommonDAL.GetARSharedReference();
            ViewBag.ISharedUI = new SelectList(ISharedUI, "ID", "Description");
            return View();
        }
    }

您可以使用 jQuery。给下拉列表一个id,像这样。

     <div id="FormDiv">
     @using (Html.BeginForm("Create", "CONTROLLER", null, FormMethod.Post, new { }))
          {
          @Html.DropDownListFor(model => model.Reference, ViewBag.ISharedUI as SelectList, "-- REFERENCE TYPE --",new {id = "dblist" })
          @Html.ValidationMessageFor(x => x.reftab)
          }
     </div>

然后使用jQuery提交其父表单

$('#dblist').on('change', function(event){
    var form = $(event.target).parents('form');
    form.submit();
});