1.后台foreach 与 html的关系
<table border="1">
@for (var i = 0; i < 10; i++)
{
@Html.Raw(i % 2 == 0 ? "<tr>" : "")
<td>
@i
</td>
@Html.Raw(i % 2 != 0 ? "</tr>" : "")
}
</table>
2.判断控件是否在页面的可视区域
(jQuery(window).scrollTop()>(jQuery('#item').offset().top+jQuery('#item').outerHeight()))||((jQuery(window).scrollTop()+jQuery(window).height())<jQuery('#item').offset().top)
3.EF GROUPBY COUNT
var results = query.GroupBy(r => new { SentDate = System.Data.Objects.EntityFunctions.TruncateTime(r.Launch.EmailDeliveredDate), EventSubTypeID = r.EmailEventSubtypeID }).Select(x => new { x.Key.SentDate, x.Key.EventSubTypeID, NumResults = x.Count() }). ToList();
当 IDENTITY_INSERT 设置为 OFF 时,不能为表中的标识列插入显式值
4.
给自增字段赋值导致的错误
5. 图片延迟加载
-1- 应用 jquery延迟加载 <script src="~/Scripts/jquery.lazyload.js"></script>
-2- <img class="lazy" data-original="' + path_imgTravel + '' + traveldata.TravelPic + '" src="/Content/base/images/load.gif" onload="AutoResizeImage(330,210,this)" alt="330 X 210"/> //data-original 是真正的图片
-3-$('html,body').animate({ scrollTop: "0px"},1000);
$("img.lazy").lazyload({ threshold: 200, effect: "fadeIn" });//延迟加载
6.判断是否为手机端 利用userAgent
public static bool isMobileDevice(string requestHeader)
{
/**
* android : 所有android设备
* mac os : iphone ipad
* windows phone:Nokia等windows系统的手机
*/
String[] deviceArray = new String[] { "android", "mac os", "windows phone","mqqbrowser","iphone","ipad" };
if (requestHeader == null)
return false;
requestHeader = requestHeader.ToLower();
for (int i = 0; i < deviceArray.Length; i++)
{
if (requestHeader.IndexOf(deviceArray[i]) > 0)
{
return true;
}
}
return false;
}
string requestHeader = Request.Headers["User-Agent"];
if (isMobileDevice(requestHeader))
{
return Redirect("http://m.usoosoo.com");
}