📄 vote.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using AjaxPro;
namespace MyDemo.Vote
{
public partial class Vote_Default : System.Web.UI.Page
{
public static int[] voteCount = { 0, 0, 0 };
protected void Page_Load(object sender, EventArgs e)
{
AjaxPro.Utility.RegisterTypeForAjax(typeof(Vote_Default));
}
#region 投票系统
[AjaxPro.AjaxMethod]
public void Vote(int index)
{
voteCount[index]++;
}
[AjaxPro.AjaxMethod]
public string GetVoteResult()
{
string result = "";
int totalCount = voteCount[0] + voteCount[1] + voteCount[2];
double width0 = (voteCount[0] + 0.0) / totalCount;
double width1 = (voteCount[1] + 0.0) / totalCount;
double width2 = (voteCount[2] + 0.0) / totalCount;
result += "<TABLE width=500 border=0 cellspacing=1 cellpadding=0 ><TR align=center bgcolor=#F4A612><TD width=90 height=25 class=v1><FONT color=#ffffff><STRONG>选项</STRONG></FONT></TD><TD width=260 class=v1><FONT color=#ffffff><STRONG>票数</STRONG></FONT></TD></TR><TR bgcolor=#FFFFFF>";
result += "<TD height=23 class=v1>·非常满意</TD><TD> <TABLE><TR><TD width=54><SPAN class=v1>";
result += voteCount[0];
result += "</SPAN></TD>" + "<TD><IMG src=red.gif width=";
result += width0*30 + "height=2></TD></TR></TABLE></TD> </TR><TR bgcolor=#FFFFFF>";
result += "<TD height=23 class=v1>·基本满意</TD><TD><TABLE> <TR> <TD width=54><SPAN class=v1>";
result += voteCount[1];
result += "</SPAN></TD>" + "<TD><IMG src=red.gif width=";
result += width1 * 30 + " height=2></TD></TR></TABLE></TD></TR><TR bgcolor=#FFFFFF>";
result += "<TD height=23 class=v1>·非常不满意</TD><TD><TABLE><TR><TD width=54><SPAN class=v1>";
result += voteCount[2];
result += "</SPAN></TD>" + "<TD><IMG src=red.gif width=";
result += width2 * 30 + "height=2></TD></TR></TABLE></TD></TR><TR bgcolor=#FFFFFF>";
return result;
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -