Asp.net mvc 部分视图未在div内渲染
所以我试着跟着我 但在我开始搜索、排序和过滤之前,我想看看这些页面是否按预期工作 不幸的是,它们不是,我一辈子也弄不明白为什么,我甚至下载了他的工作示例,只是想看看它是否与我的浏览器有关。(要下载他在第二篇文章顶部的工作示例,我不能发布超过2个链接) 自从他工作以来,我将他的视图、控制器和脚本并排地与我的进行了比较,从我所知道的情况来看,它们相互映射 因此,我最终将我的代码复制到其他地方,并将其粘贴到我的项目中,更改ActionLink以反映我使用的命名约定,并省略了我尚未实现的内容(如上所述)。而且它仍然可以工作 当我并排运行它们时,控制台中没有错误,它们加载的脚本与我添加jquery.unobstructive-ajax.js的脚本相同,只是我试图通过搜索解决方案来纠正它,但没有帮助 我不知道我做错了什么:/ 我的管理视图-与他的主索引视图相关 我唯一真正改变的是动作链接Asp.net mvc 部分视图未在div内渲染,asp.net-mvc,asp.net-mvc-5,asp.net-mvc-partialview,Asp.net Mvc,Asp.net Mvc 5,Asp.net Mvc Partialview,所以我试着跟着我 但在我开始搜索、排序和过滤之前,我想看看这些页面是否按预期工作 不幸的是,它们不是,我一辈子也弄不明白为什么,我甚至下载了他的工作示例,只是想看看它是否与我的浏览器有关。(要下载他在第二篇文章顶部的工作示例,我不能发布超过2个链接) 自从他工作以来,我将他的视图、控制器和脚本并排地与我的进行了比较,从我所知道的情况来看,它们相互映射 因此,我最终将我的代码复制到其他地方,并将其粘贴到我的项目中,更改ActionLink以反映我使用的命名约定,并省略了我尚未实现的内容(如上所述)
@{
ViewBag.Title = "Home Page";
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/bundles/bootstrap")
<script src="~/Scripts/ModalDialog.js"></script>
<style>
.testClass {
font-size: xx-large;
text-transform: capitalize;
}
</style>
<title>
Complete example of MVC pagination, filtering and sortig inside patial view with edit in modal dialog
</title>
</head>
<body style="padding-top:0">
<table style="width:100%;" border="1" cellspacing="0" cellpadding="0">
<tr>
<td style="" colspan="2">
<div id="logo" style="height:70px; background-color:rgba(86, 111, 111, 1);font: 1.5em Georgia, Times New Roman, Times, serif;">
Complete example of MVC pagination, filtering and sortig inside patial view with edit in modal dialog
</div>
<div id="navigation" style="background-color:#a4c2c2">
<a href="index" class="current">HOME</a>
</div>
</td>
</tr>
<tr style="height:600px">
<td style="width:200px;background-color: #a4c2c2; vertical-align:top; padding-top:10px; padding-left:10px">
<div>
<ul>
<li>
@Html.ActionLink("Manage Assets", "MasterDetail", "Assets", new { }, new { id = "btnCustomers", @class = "btn btn-default btn-xs" })
</li>
</ul>
</div>
</td>
<td>
<div id="contentFrame" style="width:100%; height:600px; padding-top:10px; padding-left:10px" />
</td>
</tr>
</table>
</body>
</html>
<script type="text/javascript">
$(function () {
$.ajaxSetup({cache : false})
$('#btnCustomers').click(function () {
$('#contentFrame').mask("waiting ...");
$('#contentFrame').load(this.href, function (response, status, xhr) {
$('#contentFrame').unmask("waiting ...");
});
return false;
});
});
</script>
@{
ViewBag.Title=“主页”;
布局=空;
}
@style.Render(“~/Content/css”)
@Scripts.Render(“~/bundles/modernizer”)
@Scripts.Render(“~/bundles/jquery”)
@Scripts.Render(“~/bundles/jqueryval”)
@Scripts.Render(“~/bundles/bootstrap”)
.testClass{
字体大小:xx大号;
文本转换:大写;
}
MVC分页、筛选和排序的完整示例,在模式对话框中使用“编辑”的空间视图中
MVC分页、筛选和排序的完整示例,在模式对话框中使用“编辑”的空间视图中
-
@ActionLink(“管理资产”、“主细节”、“资产”、新{}、新{id=“btn客户”、@class=“btn btn默认btn xs”})
$(函数(){
$.ajaxSetup({cache:false})
$('#btnccustomers')。单击(函数(){
$('#contentFrame')。掩码(“等待…”);
$('#contentFrame').load(this.href,函数(响应,状态,xhr){
$('contentFrame')。取消掩码(“等待…”);
});
返回false;
});
});
我的MasterDetail视图-与他的客户索引视图相关
我的桌子设置不同,因为我还没有完成他做的所有事情
@using PagedList.Mvc
@model PagedList.IPagedList<Furst_Alpha_2._0.Models.Quantities>
@{
Layout = null;
}
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/bundles/bootstrap")
<script src="~/Scripts/ModalDialog.js"></script>
<h2>Inventory Management</h2>
<p>
@Html.ActionLink("Create New", "_Create", new { id = -1 }, new { btnName = "btnCreate", @class = "btn btn-default btn-xs" })
</p>
<table class="table">
<tr>
<th>
Category
</th>
<th>
Make
</th>
<th>
Model
</th>
<th>
Type
</th>
<th>
Length
</th>
<th>
Width
</th>
<th>
Height
</th>
<th>
Weight
</th>
<th>
Description
</th>
<th>
Rental Price
</th>
<th>
Number Of Techs
</th>
<th>
Total
</th>
<th>
In User
</th>
<th>
Availability
</th>
<th></th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Assets.Category.CategoryName)
</td>
<td>
@Html.DisplayFor(modelItem => item.Assets.Make.MakeName)
</td>
<td>
@Html.DisplayFor(modelItem => item.Assets.Model.ModelName)
</td>
<td>
@Html.DisplayFor(modelItem => item.Assets.Type.TypeName)
</td>
<td>
@Html.DisplayFor(modelItem => item.Assets.Length)
</td>
<td>
@Html.DisplayFor(modelItem => item.Assets.Width)
</td>
<td>
@Html.DisplayFor(modelItem => item.Assets.Height)
</td>
<td>
@Html.DisplayFor(modelItem => item.Assets.Weight)
</td>
<td>
@Html.DisplayFor(modelItem => item.Assets.Description)
</td>
<td>
@Html.DisplayFor(modelItem => item.Assets.RentalPrice)
</td>
<td>
@Html.DisplayFor(modelItem => item.Assets.NumTechsReq)
</td>
<td>
@Html.DisplayFor(modelItem => item.total)
</td>
<td>
@Html.DisplayFor(modelItem => item.InUse)
</td>
<td>
@Html.DisplayFor(modelItem => item.Availability)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.QuantityId }, new { btnName = "btnEdit", @class = "btn btn-default btn-xs" })
@Html.ActionLink("Delete", "Delete", new { id = item.QuantityId }, new { btnName = "btnDelete", @class = "btn btn-default btn-xs" })
</td>
</tr>
}
</table>
Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) of @Model.PageCount
<div id="myPager">
@Html.PagedListPager(Model, page => Url.Action("MasterDetail", new { page, OrderID = ViewBag.OrderID }))
</div>
<script type="text/javascript">
$(function () {
$.ajaxSetup({ cache: false });
setDialogLink($('a[btnName=btnCreate]'), 'Add New Asset', 500, 600, "contentFrame", "/Assets/MasterDetail");
setDialogLink($('a[btnName=btnEdit]'), 'Edit Customer', 500, 600, "contentFrame", "/Customers/Index");
setDialogLink($('a[btnName=btnDetails]'), 'Customer Details', 500, 600, "contentFrame", "/Customers/Index");
$('a[btnName=btnDelete]').click(function (e) {
e.preventDefault();
var confirmResult = confirm("Are you sure?");
if (confirmResult)
{
$('#contentFrame').mask("waiting ...");
$.ajax(
{
url: this.href,
type: 'POST',
data: JSON.stringify({}),
dataType: 'json',
traditional: true,
contentType: "application/json; charset=utf-8",
success:function(data)
{
if (data.success) {
$('#contentFrame').load("/Customers/Index");
}
else {
alert(data.errormessage);
}
$('#contentFrame').unmask("waiting ...");
},
error: function (data) {
alert("An error has occured!!!");
$('#contentFrame').unmask("waiting ...");
}
});
}
})
$("a[btnName=FilterCustomer]").click(function (e) {
e.preventDefault();
var search = $('input[name=search]').val();
this.href = this.href.replace('xyz', search);
$('#contentFrame').mask("waiting ...");
$.ajax({
url: this.href,
type: 'POST',
cache: false,
success: function (result) {
$('#contentFrame').unmask("waiting ...");
$('#contentFrame').html(result);
}
});
});
$(".SortButton").click(function (e) {
e.preventDefault();
$('#contentFrame').mask("waiting ...");
$.ajax({
url: this.href,
type: 'POST',
cache: false,
success: function (result) {
$('#contentFrame').unmask("waiting ...");
$('#contentFrame').html(result);
}
})
});
$('#myPager').on('click', 'a', function (e) {
e.preventDefault();
$('#contentFrame').mask("waiting ...");
$.ajax({
url: this.href,
type: 'GET',
cache: false,
success: function (result) {
$('#contentFrame').unmask("waiting ...");
$('#contentFrame').html(result);
}
});
});
});
</script>
使用PagedList.Mvc
@型号PagedList.IPagedList
@{
布局=空;
}
@style.Render(“~/Content/css”)
@Scripts.Render(“~/bundles/modernizer”)
@Scripts.Render(“~/bundles/jquery”)
@Scripts.Render(“~/bundles/jqueryval”)
@Scripts.Render(“~/bundles/bootstrap”)
库存管理
@ActionLink(“Create New”,“_Create”,New{id=-1},New{btnName=“btnCreate”,@class=“btn btn default btn xs”})
类别
制作
模型
类型
长度
宽度
高度
重量
描述
租金
技术员人数
全部的
使用中
可利用性
@foreach(模型中的var项目)
{
@DisplayFor(modelItem=>item.Assets.Category.CategoryName)
@DisplayFor(modelItem=>item.Assets.Make.MakeName)
@DisplayFor(modelItem=>item.Assets.Model.ModelName)
@DisplayFor(modelItem=>item.Assets.Type.TypeName)
@DisplayFor(modelItem=>item.Assets.Length)
@DisplayFor(modelItem=>item.Assets.Width)
@DisplayFor(modelItem=>item.Assets.Height)
@DisplayFor(modelItem=>item.Assets.Weight)
@DisplayFor(modelItem=>item.Assets.Description)
@DisplayFor(modelItem=>item.Assets.RentalPrice)
@DisplayFor(modelItem=>item.Assets.NumTechsReq)
@DisplayFor(modelItem=>item.total)
@DisplayFor(modeleItem=>item.InUse)
@DisplayFor(modelItem=>item.Availability)
@ActionLink(“编辑”,“编辑”,新的{id=item.QuantityId},新的{btnName=“btnEdit”,@class=“btn btn default btn xs”})
@ActionLink(“Delete”,“Delete”,new{id=item.QuantityId},new{btnName=“btnDelete”,@class=“btn btn default btn xs”})
}
@Model.PageCount的@页(Model.PageCount// GET: Assets
public ActionResult Manage()
{
return View();
}
// GET: MasterDetail
public ActionResult MasterDetail(int? page)
{
ApplicationUser user = System.Web.HttpContext.Current.GetOwinContext().GetUserManager<ApplicationUserManager>().FindById(User.Identity.GetUserId());
//ApplicationUser user = db.Users.First(u => u.Id == userr.Id);
var assets = db.Quantities.Where(a => a.VendorId == user.VendorId).OrderByDescending(a => a.AssetId);
int pageNumber = page ?? 1;
int pageSize = 3;
return PartialView(assets.ToPagedList(pageNumber, pageSize));
}
@Html.PagedListPager(Model, page => Url.Action("_MasterDetail", new { page, OrderID = ViewBag.OrderID }))
@Html.PagedListPager(Model, page => Url.Action("MasterDetail", new { page, OrderID = ViewBag.OrderID }))
<script type="text/javascript">
$(function () {
$.ajaxSetup({cache : false})
$('#btnCustomers').click(function () {
//$('#contentFrame').mask("waiting ...");
waitingDialog.show("Please wait while we prepare your inventory ...");
$('#contentFrame').load('@Url.Action("MasterDetail","Assets")', function () {
setTimeout(function () {
waitingDialog.hide();
}, 1000);
});
//$.ajax({
// type: 'GET',
// url: '@Url.Content("~/Assets/MasterDetail")',
// data: -1,
// success: function (data) {
// $('#contentFrame').innerHtml = waitingDialog.hide();
//$('#contentFrame').load('@Url.Action("MasterDetail","Assets")');
// }
//})
//$('#contentFrame').load(this.href, function (response, status, xhr) {
// $('#contentFrame').unmask("waiting ...");
//});
return false;
});
});
</script>