62,040
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Test</title>
</head>
<body>
<form id="form1" runat="server" enctype="multipart/form-data">
<div>
<asp:Label ID="Label1" runat="server" Text="0"></asp:Label>
<select id="test" runat="server" enableviewstate="true">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
int i = 1;
protected void Page_Load(object sender, EventArgs e)
{
if (ViewState["i"] != null)
i = (int)ViewState["i"];
i++;
ViewState["i"] = i;
Label1.Text = i.ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
}
}