!
"
# $ %& #
' ()
$ %& $ $ %&
+
, ! $ %& -."
'
,
/
$ %&
$ %& ,
0
$ %&
$ %&
+
12
0
3 4 5
+ +
' +
3 5 5
&3* + $ 6
789
:.; .
4 $ +
< = + 0
<
4 ) 0
= 4 *
'
static string s = [Link]["cnstr"];
public static DataSet GetData(string selstr)
{
SqlConnection cn = new SqlConnection(s);
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(selstr, cn);
[Link](ds);
return ds;
}
% = 4
= + # +
<
= 4 = +
+ 0 +
= 4
0 # >, *
protected void Button1_Click(object sender, EventArgs e)
{
DataSet myds;
if (ViewState["dsdata"] == null)
{
myds = [Link]("select * from jobs");
ViewState["dsdata"] = myds;
}
else
myds = (DataSet)ViewState["dsdata"];
[Link] = [Link][0];
[Link]();
}
, $ %& -.
, $
' $ %&
?
' ' @$
&3*
< 7
( 8
<input type="hidden" id="Message" value="Hello..how r u?"
runat="server" />
0 *
! "#
%
@ 3
! " 3
7
$ ( 8
< # >, *
[Link] = [Link];
0
3 *
"
#
,
,
, *
3
! A "
! "
&3 5
B(#
,
, ? ' 3
!
' ? $$) !
$ $ ) "
"
0 3 $
3
"
# $
C $ <
C $
C $
$ , 3
3 2
= ,
<script language="javascript">
function SetCookie(cName, cValue, expDays) {
var today = new Date();
var expire = new Date();
if (exDays == null || expDays == 0)
expDays = 4;
[Link]([Link]() + 3600000 * 24 * expDays);
[Link] = cName + "=" + escape(cValue)
+ ";expires=" + [Link]();
}
</script>
function GetCookie(cName) {
if ([Link] > 0) {
startIndex = [Link](cName + "=");
if (startIndex != -1) {
startIndex =startIndex + [Link] + 1;
endIndex = [Link](";", startIndex);
if (endIndex == -1) endIndex = [Link];
return unescape([Link](startIndex,
endIndex));
}
}
return "";
}
<body>
<form id="form1" runat="server">
<div>
<script language="javascript">
SetCookie("mycookie", "hello", 3);
</script>
<button id="btn1" onclick="f1()"></button>
</div>
</form>
</body>
</html>
*
function f1() {
[Link] = GetCookie("mycookie");
}
C $
" %
< $ %& *
D E ,
D ' , %&
$ E ,
& " ! ' ( "
<
3 3 3 3
# >, *
HttpCookie x = new HttpCookie("user");
[Link] = [Link];
[Link](x);
[Link]("Information stored");
$
>) *
if ([Link]["user"] != null)
[Link] = [Link]["user"].Value;
else
[Link] = "Guest";
" %
3 !
3 "<
3
HttpCookie x = new HttpCookie("user");
[Link] = [Link];
[Link] = [Link](2); //expires in 2 days
[Link](x);
3 3 FE ( ?
< <
3 G.
3
$HD'
#
F< ( ? 0
3
3
$ <
)* (
+ ,-+ ,.+ * ,/+ ,.+ * ,0
&3*4 3I :B.A :-.A :J.
3 4 3
0
1
E !
E 6
7 3# 3B8
9"; 3 3
! "
E E !
7 3I :8
K 3# 3B 3"
;
! "
) # 3B 3:E 6
789
;
' E E 3 !"
0
E E !" 3
E
345 !
$ %& $ %&
%& 4 ,)E
$ %& 4
4 3
3
D
$ 3
$ %&
$ %& $
0
< 4
3
4
# $ %& -.
&3* 6738
9:B.;
6
7 89
: ;
$ 6
789:B;! "
$
$
? $
<
$
protected void btnApplication_Click(object sender, EventArgs e)
{
if (Application["a"] == null)
Application["a"] = 0;
Application["a"] = Convert.ToInt32(Application["a"]) + 1;
[Link] = Application["a"].ToString();
}
protected void btnSession_Click(object sender, EventArgs e)
{
if (Session["b"] == null)
Session["b"] = 0;
Session["b"] = Convert.ToInt32(Session["b"]) + 1;
[Link] = Session["b"].ToString();
}
# $
!
! 4 "
4 $ , *
$
,
$
,
4
< 3
%
,
$
,
$
, 3
&3*$ *
,
<
D
$
$ *
#
$ $
= 3 $
3 '
= 3 +$
= 3 $ %& D %
3 = 3
3 = 3
= 3
$ *
B >$ *
< %
5
- >& *
< $ %&
J >& *
0
>&
2 $ >$ *
0 $ >$
G $ >& *
<
0 $ > !
"
<
D D @ D
' D
@ D
$
$ >$ B
$ @ D
$ >& 0
= 3
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
Application["TotalUsers"] = 0;
Application["OnlineUsers"] = 0;
void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
Application["TotalUsers"] =
Convert.ToInt32(Application["TotalUsers"]) + 1;
Application["OnlineUsers"] =
Convert.ToInt32(Application["OnlineUsers"]) + 1;
void Session_End(object sender, EventArgs e)
{
// Code that runs when a session ends.
Application["OnlineUsers"] =
Convert.ToInt32(Application["OnlineUsers"]) - 1;
}
% >) *
[Link] = 1; //Session expires in 1 minute
[Link] = Application["TotalUsers"].ToString();
[Link] = Application["OnlineUsers"].ToString();
' >)
$ >)
0 L M *
<[Link]>
<sessionState timeout="5"></sessionState>
....
</[Link]>
$ !
"
#
$ %&
?
$ %& $ $
D $/)$ ! "
3* ' !
' '
3
$ %& *
= $ !, $ "
$ $ %& $ $ $
= @
L $ M
&3*
<sessionState mode="StateServer"
stateConnectionString="[Link]" ..... >
</sessionState>
0 $ %& $/)$
> 3
%&
*
<sessionState mode="SQLServer" stateConnectionString="<connection
string>” ... >
</sessionState>
4 " !3* ' !
'
B (
- 4 5 5 $
? 5