[ASP.NET C# 编写一个投票选举网页] 下面是我按 winform 写的
程序代码:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using namespace asp选举3 { public partial class _Default : System.Web.UI.Page { int x1=0, x2, x3, all, allstick; string[] asave = new string[9];//存储 protected void Page_Load(object sender, EventArgs e) { } protected void Buttono_Click(object sender, EventArgs e) { all = int.Parse(TextBoxAll.Text); Labeltest.Text="Buttono_Click" + all; allstick = all; } protected void Buttonx1_Click(object sender, EventArgs e) { if (all > 0) { x1 = x1 + 1; all = all - 1; Labeltest.Text = "Buttonx1_Click if (all > 3)" + all; } if (all ==0) { Labeltest.Text = "Buttonx1_Click else if (all == 0)" + all; Buttonx1.Enabled = false; Buttonx2.Enabled = false; Buttonx3.Enabled = false; } } public string abc { get; set; } protected void Buttonx2_Click(object sender, EventArgs e) { if (all > 0) { x2 = x2 + 1; all = all - 1; Labeltest.Text = "Buttonx2_Click if (all > 0)" + all; } if (all == 0) { Labeltest.Text = "Buttonx2_Click else if (all == 0)" + all; Buttonx1.Enabled = false; Buttonx2.Enabled = false; Buttonx3.Enabled = false; } } protected void Buttonx3_Click(object sender, EventArgs e) { if (all > 0) { x3 = x3 + 1; all = all - 1; Labeltest.Text = "Buttonx3_Click if (all > 0)" + all; } if (all == 0) { Labeltest.Text = "Buttonx3_Click else if (all == 0)" + all; Buttonx1.Enabled = false; Buttonx2.Enabled = false; Buttonx3.Enabled = false; } } } }