//JS返回上一页 弊端多次返回会比较乱. 界面布局尽量左右结构 去掉返回功能
<a href="javascript:history.go(-1);">返回</a>
//隐藏DIV
<div id="hidItemCode">
<script>
$(document).ready(function () {
$("#hidItemCode").hide();
});
</script>
//隐藏行
<tr style="display:none"></tr>
//关于设置Html.EditorFor宽度及高度怎么设定 只用Html.TextBoxFor有效
//有类似Html.TextAreaFor的Object htmlAttributes参数时 才可以设置
@Html.TextBoxFor(model => model.startTenderDate_T, new { style = "Width:90px" })
<style>
.minWidth {
Width: 95px;
}
</style>
<td>@Html.TextBoxFor(model => model.cutoffTenderDate_T, new { @class = "minWidth" })
ASP.NET MVC 开发基础类 MODEL 使用技巧
必填属性 + 提示消息
/// <summary>
/// 客户编码 (关联字段)
/// </summary>
[Display(Name="客户编码")]
[Required(ErrorMessage = "客户编码不能为空,请输入")]
public string C_customerCode_C { get; set; }
不生成界面属性
/// <summary>
/// 修改日期
/// </summary>
[Display(Name="修改日期")]
[ScaffoldColumn(false)]
public Nullable<System.DateTime> updateDate { get; set; }
数据库新增字段修改步骤
1.新增数据字段(非必填)
2.修改Models 和 Mapping
3.在创建Action中 赋值新增的字段
如果是必填的字段的话,还需要修改 新增,编辑,查询 等界面
排序 LinQ
var pInfo = from p in db.ProjectInformations
orderby p.createDate_T descending (ascending)
select p;
筛选 LinQ 前10项
var pInfo = (from p in db.ProjectInformations
orderby p.createDate_T descending
select p).Take(10) ;
不引用模板页
@{
Layout = null;
}
跳转
RedirectToAction("Index");
return RedirectToAction("getItemInfoByItemCodeTab", "ProjectInformation", new { ItemCode = projectinformation.itemCode_C });
@Html.ActionLink("返回", "getItemInfoByItemCodeTab", "ProjectInformation", new { ItemCode = @ViewBag.itemCode },"")
日期
@Html.TextBoxFor(model => model.dateReceiptTenders_T, new { @class = "easyui-datetimebox",style = "Width:95px"})
修改精度
this.Property(t => t.thbzj_D).HasPrecision(15, 6).HasColumnName("thbzj_D");
@Html.TextBoxFor(model => model.thbzj_D, new { @class = "minWidth" })
DisplayFor |默认精度保留后俩位 还会四舍五入
@Html.DisplayTextFor(model => model.proInfo.zbje_D) | 显示数据格式
easyui 与 默认mvc样式冲突的样式如下:
在Content文件夹中 site.css 删除以下样式即可
/* tables
----------------------------------------------------------*/
table {
border-collapse: collapse;
border-spacing: 0;
margin-top: 0.75em;
border: 0 none;
}
th {
font-size: 1.2em;
text-align: left;
border: none 0px;
padding-left: 0;
}
th a {
display: block;
position: relative;
}
th a:link, th a:visited, th a:active, th a:hover {
color: #333;
font-weight: 600;
text-decoration: none;
padding: 0;
}
th a:hover {
color: #000;
}
th.asc a, th.desc a {
margin-right: .75em;
}
th.asc a:after, th.desc a:after {
display: block;
position: absolute;
right: 0em;
top: 0;
font-size: 0.75em;
}
th.asc a:after {
content: '▲';
}
th.desc a:after {
content: '▼';
}
td {
padding: 0.25em 2em 0.25em 0em;
border: 0 none;
}
tr.pager td {
padding: 0 0.25em 0 0;
}
Json列表
List<UR_ControllerAction> ur = (from u in db.UR_ControllerAction
select u).ToList();
return Json(ur, JsonRequestBehavior.AllowGet);
JavaScript location.href 属性
Location 对象的 href 属性用于设置或取得当前完整的 URL,语法如下:
location.href = URL
JS 与 jQuery 注意事项
$(document).ready(function () {}
中不要带
function removeit() {
.....
}
方法 有可能不识别 在同一<script type="text/javascript">下面即可
设置分辨率
var winWidth = screen.width;
$("#titleTable").attr("style", "width:" + winWidth * 0.85+"px");
alert(":" + $("#titleTable").attr("style"));
问题:
MVC 怎么实现后面的 #tabs-4
数据库设计:
所有的数据都应该有一个状态.Exist status 存在状态.如果数据被删除了 就应该把这个状态设置为0 否则有效数据都为1
BUG:
序列化类型为“System.Data.Entity.DynamicProxies.UR_ControllerActionR 对象时检测到循环引用。
db.Configuration.LazyLoadingEnabled = false;
db.Configuration.ProxyCreationEnabled = false;
JS四舍五入.
js: Math.round(7/2)
关闭缓存,
$.ajaxSetup ({
cache: false //关闭AJAX相应的缓存
});