本文介绍了刷新局部视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Asp.NET MVC5开发Web应用程序。由于我没有太多经验,我使用JQuery和Partial View时遇到了一个功能。
我有一个侧面菜单作为页面中的局部视图。这个局部视图包含一个从模型填充的DropdownList,它工作正常。但是,我想根据所选的下拉列表显示数据库中的项目列表,该选项不起作用。
请帮忙。
谢谢
我尝试过:
Hi,
I am developing a Web Application with Asp.NET MVC5. As I dont have much experience, I am stuck with a functionality using JQuery and Partial View.
I have a Side Menu as a partial view in a page. This partial view contains a DropdownList which is populated from model, and it works fine. However, I want to display a list of items from the db when the dropdown is selected, based on the selection, which is not working.
Please help.
Thanks
What I have tried:
Partial View (_UserPartialView)
$('#dropdown').change(function(){
var item = $(this).val();
$.get("/Controller/GetItems/" + item, function(data)
{
('#target').html(data);
});
控制器
Controller
public ActionResult (int id)
{
var test = db.Users.Where(e => e.cId = id);
return PartialView(" _UserPartialView", test);
}
推荐答案
控制器
Controller
public ActionResult (int id)
{
var test = db.Users.Where(e => e.cId = id);
return PartialView(" _UserPartialView", test);
}
这篇关于刷新局部视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!