js 獲取標籤name屬性javascript
this.getAttribute("name") | document.getElementById(id).getAttribute('name')css
CSS操做背景圖片html
background-size:100% 100%;java
background-size:cover;jquery
background-size:cover;ajax
background-size:auto;正則表達式
運行裏敲:dcomcnfg,打開組件服務sql
透明divjson
filter:alpha(opacity=25);-moz-opacity:0.25;-khtml-opacity: 0.25;opacity: 0.25;瀏覽器
js設置樣式
document.getElementsByTagName("img").style.position='absolute';
===============================================================正則表達式
代碼:
var reg=/^\d{3,4}-\d{7,8}(-\d{3,4})?$/;
if(!reg.test($("#aa").val()))
{
}
/^\d{3,4}-\d{7,8}(-\d{3,4})?$/電話驗證
/^0{0,1}(13[0-9]|15[7-9]|153|156|18[7-9])[0-9]{8}$/手機驗證
/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/郵箱驗證
/^[0-9]*[1-9][0-9]*$/正整數
===============================================================js獲取asp.net中的變量
var aa="<%=UploadID%>";
===============================================================jquery 移入移出
mouseenter,mouseleave
===============================================================.net 綁定數據時格式化時間
<%# Eval("GOODS_VALID_START", "{0:yyyy-MM-dd}")%>
===============================================================T-sql隨機查詢
select top 3 * from V_COURSE_GOODS_INFO order by newid()
===============================================================js獲取瀏覽器寬度高度
document.documentElement.clientWidth
document.documentElement.clientHeihgt
===============================================================容許上傳一次
'multi': false,//加上只容許上傳一次
'queueSizeLimit': 1, //加上只容許上傳一次
===============================================================刪除
http://v.polyv.net/uc/services/rest?method=delVideoById&writetoken=7broEB6eVLiRuH8-RnTg7AiQ03Vw8bQR&vid=543e6e20ae0a341fe22c44e3a17eb593_5
===============================================================這裏記錄訪問量
window.onload=function(){
if(!window.name){
window.name = 'FirstLoad';
var infoid='1732';
$.post("Ajax.aspx",{infoid:infoid,func:"RecordCount"},
function(data){
});
}}
===============================================================jquery獲取select的值
jQuery("#select1 option:selected").text();
===============================================================腳本傳綁定值
OnClientClick='<%# "showrole("+Eval("USER_ID")+")" %>'
=========================================================================================================彈出框
<script src="../../artDialog/artDialog.source.js?skin=default" type="text/javascript"></script>
/**
* 確認
* @param{String}消息內容
* @param{Function}肯定按鈕回調函數
* @param{Function}取消按鈕回調函數
*/
artDialog.confirm = function (content, yes, no) {
return artDialog({
top: '150px',
id: 'Confirm',
icon: 'question',
fixed: true,
lock: true,
background: '#333', // 背景色
opacity: 0.60, // 透明度
content: content,
ok: function (here) {
//return yes.call(this, here);
artDialog.tips("操做成功", 1.5);
}
// cancel: function (here) {
// //return no && no.call(this, here);
// }
});
};
/**
* 短暫提示
* @param{String}提示內容
* @param{Number}顯示時間 (默認1.5秒)
*/
artDialog.tips = function (content, time) {
return artDialog({
top: '30px',
id: 'Tips',
title: false,
cancel: false,
fixed: true,
lock: false
})
.content('<div class="tanchu">' + content + '</div>')
.time(time || 1.0);
};
===============================================================js禁用滾動條
$("body").css({ "overflow": "scroll", "overflow-y": "hidden" });
$("body").css({ "overflow": "scroll", "overflow-y": "" });
===============================================================外圍邊框樣式
outline
===============================================================Asp.net控制TextBox只能輸入數字
style="ime-mode:disabled" onkeypress="if (event.keyCode<48 || event.keyCode>57) event.returnValue=false;"
===============================================================上傳圖片業務邏輯
//頭像
if (UploadLocalFile.HasFile)
{
FileInfo file = new FileInfo(Server.MapPath("~/UpLoad/User_Img/" + UploadLocalFile.FileName));
if (file.Exists)
{
this.doScript("alert('圖片已存在,請更改文件名稱')");
return null;
}
//後綴
string houzhui = Path.GetExtension(UploadLocalFile.FileName).ToLower();
if (houzhui != ".jpg" && houzhui != ".png" && houzhui != ".gif" && houzhui != ".bmp" && houzhui != ".jpeg")
{
this.doScript("alert('圖片格式不支持,目前支持(.jpg .png .gif .bmp .jpeg)')");
return null;
}
//大小
if (UploadLocalFile.PostedFile.ContentLength > 1024 * 1024 * 2)
{
this.doScript("alert('圖片大小不能超過2M')");
return null;
}
info.Stu_p_w_picpath = UploadLocalFile.FileName;
UploadLocalFile.SaveAs(Server.MapPath("~/UpLoad/User_Img/" + UploadLocalFile.FileName));
}
===============================================================刪除圖片
if (File.Exists(Server.MapPath("../UpLoad/SchoolLogo/" + sei.School_logo)))
File.Delete(Server.MapPath("../UpLoad/SchoolLogo/" + sei.School_logo));
===============================================================查詢爲空的字段
school_type is null
===============================================================保存時判斷
<script type="text/javascript">
$(function(){
$("#infoSave").click(function(){
var yesno=true;
var message="";
if($("#DEP_NAME").val()=="")
{
message+="領域名稱不能爲空<br/>";
yesno=false;
}
if($("#DEP_SORT").val()=="")
{
message+="排序順序不能爲空<br/>";
yesno=false;
}
if(!yesno)
{
msg(message);
}
return yesno;
});
});
function msg(aa)
{
artDialog.confirm(aa);
}
</script>
===============================================================彈出頁面
//window.open ('page.html','newwindow','height=100,width=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no')
//腳本運行後,main.aspx將在新窗體newwindow中打開,寬爲100,高爲400,距屏頂0象素,屏左0象素,無工具條,無菜單條,無滾動條,不可調整大小,無地址欄,無狀態欄。請對照。
//doScript("window.open('study/main.aspx','newwindow','height=100,width=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no')");
===============================================================不在當前活動窗口,倒計時關閉
//不在當前活動窗口,倒計時關閉【document.hasFocus():鼠標是否在該網頁內活動.】
var sumTime = 600 //總時間
var nowTime = sumTime
window.setInterval(getTime,1000);
function getTime()
{
if(document.hasFocus()==false)
{
nowTime = nowTime -1;
}
else
{
nowTime = sumTime;
}
if(nowTime < 0)
{
window.close();
}
}
===============================================================div遮罩
$("#selectType").click(function(){
var w = document.documentElement.clientWidth;
var h = document.documentElement.clientHeight;
var l = document.documentElement.clientWidth/2-$("#treeDemodiv").width()/2;
var t = document.documentElement.clientHeight/2-$("#treeDemodiv").height()/2;
$("#zhezhao").css({ "width": w + "px", "height": h + "px" });
$("#treeDemodiv").css({ "width": w + "px", "height": h + "px" });
$("#zhezhao").fadeIn(300);
$("#treeDemodiv").fadeIn(300);
});
<div id="zhezhao" style="display:none;filter:alpha(opacity=25);-moz-opacity:0.25;-khtml-opacity: 0.25;opacity: 0.25;position:fixed;background:#000;z-index:9"></div>
===============================================================獲取IE版本
var isIE=navigator.userAgent.match(/MSIE (\d)/i);
isIE=isIE?isIE[1]:undefined;
alert(isIE);
===============================================================獲取IE文檔模式
document.documentMode
===============================================================防止SQL注入驗證
private static readonly Regex RegSystemThreats =
new Regex(@"\s?or\s*|\s?;\s?|\s?drop\s|\s?grant\s|^'|\s?--|\s?union\s|\s?delete\s|\s?truncate\s|" +
@"\s?sysobjects\s?|\s?xp_.*?|\s?syslogins\s?|\s?sysremote\s?|\s?sysusers\s?|\s?sysxlogins\s?|\s?sysdatabases\s?|\s?aspnet_.*?|\s?exec\s?",
RegexOptions.Compiled | RegexOptions.IgnoreCase);
===============================================================
var jsonobj=eval('('+data+')');
===============================================================框架問題
格式爲png圖片的img觸發不了事件,能夠把圖片換位gif格式的
===============================================================Cache的使用
若是在一個獨立的類文件裏,實例化成一個Cache cache = HttpRuntime.Cache;
===============================================================Session在管道事件中的調用
Application_PostAcquireRequestState事件
HttpSessionState Session = HttpContext.Current.Session;
===============================================================ajax設置爲同步
$().ajaxSetup({async: false}); //全局設爲同步
===============================================================測試性能時間差
var timer = Stopwatch.StartNew();
SomeCodeToTime();
timer.Stop();
Console.WriteLine("Method took {0} ms", timer.ElapsedMilliseconds);
===============================================================css圓角
#gaga{border:3px solid #f00;border-radius: 5px 6px 7px 8px;}
5px表明的是左上角的弧度;
6px表明的是右上角的弧度;
7px表明的是右下角的弧度;
8px表明的是左下角的弧度;
===============================================================group by
select course_name,stu_cnname from V_ORDER_COURSE_FULL_INFO group by course_name,stu_cnname
查詢的不重複的數據
===============================================================sql查詢爲空不爲空的數據
and LIMIT_START_DATE is not null不爲空
and LIMIT_START_DATE is null爲空