毕设开发中细节总结

1.存储过程返回受影响行数
set nocount off

2.aspx后台文件中调用bll层的方法即使是static方法,也需要实例化对象XXBLL b=new XXBLL();否则出现未将对象引用设置到对象实例的错误,且是在DAL中报错。(为此折腾了整整半天时间,还以为是ajax方法或者后台DAL层写错了,但是我还是不知道为何会如此)。

3.无论页面高度怎么变,页脚始终保持位于页面底部
html, body { margin:0; padding:0; height:100%; }
#container { min-height:100%; position:relative; }
#body { padding-bottom:60px; /* Height of the footer 这很关键*/ }
#footer { position:absolute; bottom:0; 100%; height:60px;/* Height of the footer 这很关键*/ }

<div id="container"><div id="body"></div><div id="footer"></div></div>

4.jquery $.post()方法处理后台传来的json数据
$.post("/Handler.ashx", { command: "GetMedToSend", medname: MedName.val().trim() }, function (res) {
alert(res);
res = $.parseJSON(res);//将json转换为jq对象
t = "";
$.each(res, function (i, item) {
t += "<tr>";
t += "<td>" + item.MedId + "</td>";
t += "<td>" + item.MedName + "</td>";
t += "<td>" + item.Unit+ "</td>";
t += "<td>" + item.Form + "</td>";
t += "<td>" + item.Specification + "</td>";
t += "<td>" + item.Producer + "</td>";
t += "<td>" + item.Type + "</td>";
t += "<td>" + item.Price + "</td>";
t += "<td>" + item.Num + "</td>";
t += "<td>" + item.InStockId + "</td>";
t += "</tr>";
});
$("#table").empty();
$("#table").append(t);
});
这是将数据通过附加到table中进行展示,但要注意$.each方法中的item.字段名,这个字段名一定要和数据库出查询出的字段名一样,否则table中数据显示为undefined。

5.根据tr获取td,各种获取
6.jQuery中的乘法,加法
var a=123;var b=123; var s=a+b;这样是字符串的相加,要想数字相加:var s=a*1+b*1;

7.$(id的变量名)的格式为$("#"+变量名)

8.jQuery中json日期格式转换
function ToDate(jsondate) {
jsondate = jsondate.replace("/Date(", "").replace(")/", "");
if (jsondate.indexOf("+") > 0) {
jsondate = jsondate.substring(0, jsondate.indexOf("+"));
}
else if (jsondate.indexOf("-") > 0) {
jsondate = jsondate.substring(0, jsondate.indexOf("-"));
}
var date = new Date(parseInt(jsondate, 10));
var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
var seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
return date.getFullYear()
+ "年"
+ month
+ "月"
+ currentDate
+ "日"
+ " "
+ hours
+ ":"
+ minutes
+ ":"
+ seconds;
}

原文地址:https://www.cnblogs.com/lpynb/p/5639237.html