一、repeater控件,在前臺獲取數據的時候,獲取的是被綁定數據的某項屬性。當其javascript
不具備屬性時就會報錯。(好比我用struct建立了一個包含person類和int型數據時html
,把List<struct>綁定到repeater時,獲取數據就會報錯,緣由,struct是值類型java
。)ajax
二、關於前臺SessionId的問題。因爲asp.net,給前臺傳入一個SessionId的cookie安全
的時候,默認httponly=true;因此致使前臺js不可以讀取到該cookie。因此須要cookie
在後臺設置該cookie的httponly爲false;asp.net
三、ajax真好用dom
四、網上流傳的設置cookie的expires中有關於Date對象的用法,我複製過來之後,函數
出現。.toUTCString()不是函數的問題。this
後來更改後沒有了問題。附代碼:
/******************這是我寫的*****************************/
function checkcookie() {
if (document.cookie.length > 0) {
var posstart = document.cookie.indexOf
("ASP.NET_SessionId=");
if (posstart != -1) {
posstart = posstart - 0 + "ASP.NET_SessionId=".length
;
var posend = document.cookie.indexOf(";",posstart);
if (posend == -1)
posend = document.cookie.length;
var str = document.cookie.substring(posstart,posend);
var d = new Date();
d = d.setTime(d.getTime() + (30 * 24 * 60 * 60 *
1000));
var date = new Date(d);
document.cookie = "ASP.NET_SessionId=" + str + ";
expires=" + date.toUTCString() + "; path=/";
}
}
}
/**********************下面是網上搜到的****************************/
<html>
<head>
<script language=
"javascript"
>
function Window_Load(){
setCookie(
"name"
,
"111"
);
//臨cookie
setCookie(
"age"
,
"222"
,24 * 7);
//保存7
setCookie(
"address"
,
"333"
,24,
"/"
);
//保存1,path根目錄
//設定cookie安全(secure=true),能HTTPS或與其安全協議
//鏈接起候才傳輸
setCookie(
"phone"
,
"444"
,24,
"/"
,
"."
,
false
);
alert(document.cookie);
alert(getCookie(
"age"
));
//刪除名稱"age"cookie
removeCookie(
"age"
)
alert(document.cookie);
//刪除名稱"address"cookie,設置設定path,所刪除
//須要傳入應path
removeCookie(
"address"
,
"/"
)
alert(document.cookie);
}
function setCookie(name,value,hours,path,domain,secure){
var
cdata = name +
"="
+ value;
if
(hours){
var
d =
new
Date();
d.setHours(d.getHours() + hours);
cdata +=
"; expires="
+ d.toGMTString();
}
cdata +=path ? (
"; path="
+ path) :
""
;
cdata +=domain ? (
"; domain="
+ domain) :
""
;
cdata +=secure ? (
"; secure="
+ secure) :
""
;
document.cookie = cdata;
}
function getCookie(name){
var
reg = eval(
"/(?:^|;\\s*)"
+ name +
"=([^=]+)(?:;|$)/"
);
return
reg.test(document.cookie) ? RegExp.$1 :
""
;
}
function removeCookie(name,path,domain){
this
.setCookie(name,
""
,-1,path,domain);
}
</script>
</head>
<body onload=
"Window_Load();"
>
</body>
</html>