ASP.Net/Development/ViewState — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 11:51, 26 мая 2010
ViewState property example
<%@ Page Language="vb" %>
<html>
<head>
<title>ViewState property example</title>
<script runat="server">
Sub Page_Load()
Dim LocalColor As System.Drawing.Color
If IsPostBack Then
LocalColor = CType(ViewState("LabelColor"), System.Drawing.Color)
If LocalColor.Name = "Black" Then
LocalColor = System.Drawing.Color.Red
Else
LocalColor = System.Drawing.Color.Black
End If
Message.ForeColor = LocalColor
Message.Text = "Label color is " & LocalColor.Name
ViewState("LabelColor") = LocalColor
Else
Message.ForeColor = System.Drawing.Color.Black
LocalColor = Message.ForeColor
Message.Text = "Label color is " & LocalColor.Name
ViewState("LabelColor") = LocalColor
End If
End Sub
</script>
</head>
<body>
<form runat="server">
<asp:button id="button"
text="Click to change label color"
runat="server"/>
<asp:label id="Message" runat="server"/>
</form>
</body>
</html>