注册 登录
编程论坛 ASP.NET技术论坛

[ASP.NET C# 编写一个投票选举网页] 下面是我按 winform 写的

Dramalife 发布于 2014-07-29 22:22, 1696 次点击
程序代码:





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;
            }
        }
    }
}
5 回复
#2
Dramalife2014-07-29 22:25
总票数减为0 时按钮不可用
现象:不管票数是多少,点一下候选人,按钮就不可用了。不知道是不是和win form有区别
#3
Dramalife2014-07-29 22:26
textbox输入总票数,
确定按钮 protected void Buttono_Click(object sender, EventArgs e)
三个候选人按钮 protected void Buttonx1_Click(object sender, EventArgs e)
#4
yms1232014-07-30 14:08
能否把界面贴出来,还有就是webform和winform的事件处理机制是不一样的,所以winform管用的代码webform不一定管用。
#5
Dramalife2014-08-04 16:34
回复 4 楼 yms123
只有本站会员才能查看附件,请 登录
这是截图,谢谢!
#6
Dramalife2014-08-04 16:46
回复 4 楼 yms123
我多看看书吧,谢谢您了  。删帖吧,没价值。
1