资源简介
说明:
用C#语言实现的ASP.NET在线投票系统的简单例子,可以显示投票人数,投票百分比例对比等,使用Cookie技术实现 ^_^
代码片段和文件信息
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
{
protected void Page_Load(object sender EventArgs e)
{
}
protected void ImageButton1_Click(object sender ImageClickEventArgs e)
{
string userIP = Request.UserHostAddress.ToString();
HttpCookie oldCookie = Request.Cookies[“userIP“];
if (oldCookie == null)
{
int flag = RadioButtonList1.SelectedIndex;
switch (flag)
{
case 0:
Component.WriteCount(Server.MapPath(“Result1.txt“));
break;
case 1:
Component.WriteCount(Server.MapPath(“result2.txt“));
break;
case 2:
Component.WriteCount(Server.MapPath(“Result3.txt“));
break;
}
Clientscript.RegisterStartupscript(this.GetType() ““ “alert(‘投票成功!‘)“ true);
HttpCookie newCookie = new HttpCookie(“userIP“);
newCookie.Expires = DateTime.MaxValue;
newCookie.Values.Add(“IPAddress“ userIP);
Response.AppendCookie(newCookie);
}
else
{
string userOldIP = oldCookie.Values[“IPAddress“];
if (userIP.Trim() == userOldIP.Trim())
{
Clientscript.RegisterStartupscript(this.GetType() ““ “alert(‘一个IP地址只能投一次票,谢谢您的参与!‘)“ true);
}
else
{
HttpCookie newCookie = new HttpCookie(“userIP“);
newCookie.Values.Add(“IPAddress“ userIP);
newCookie.Expires = DateTime.MaxValue;
Response.AppendCookie(newCookie);
int flag = RadioButtonList1.SelectedIndex;
switch (flag)
{
case 0:
Component.WriteCount(Server.MapPath(“Result1.txt“));
break;
case 1:
Component.WriteCount(Server.MapPath(“result2.txt“));
break;
case 2:
Component.WriteCount(Server.MapPath(“Result3.txt“));
break;
}
Clientscript.RegisterStartupscript(this.GetType() ““ “alert(‘投票成功!‘)“ true);
}
}
}
} 属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2011-11-17 17:26 Vote\
目录 0 2011-11-17 17:02 Vote\App_Code\
文件 700 2011-11-17 17:05 Vote\App_Code\Component.cs
文件 1622 2011-11-17 17:27 Vote\Default.aspx
文件 2622 2011-11-17 17:26 Vote\Default.aspx.cs
目录 0 2011-11-17 16:56 Vote\Images\
文件 100734 2010-03-25 15:34 Vote\Images\1.jpg
文件 111734 2010-03-25 15:32 Vote\Images\2.jpg
文件 1848 2010-03-25 15:37 Vote\Images\dc_03.gif
文件 1790 2010-03-25 15:37 Vote\Images\dc_05.gif
文件 1539 2010-03-25 15:35 Vote\Images\fh_03.gif
文件 4230 2011-11-17 17:33 Vote\Result.aspx
文件 1323 2011-11-17 17:39 Vote\Result.aspx.cs
文件 3 2011-11-17 17:26 Vote\Result1.txt
文件 4 2011-11-17 17:25 Vote\Result2.txt
文件 3 2011-11-17 17:39 Vote\Result3.txt
文件 761 2011-11-17 17:28 Vote\st
文件 292 2011-11-17 17:10 Vote\web.config
相关资源
- C# TIP文件生成和拆解
- C#解析HL7消息的库135797
- C# OCR数字识别实例,采用TessnetOcr,对
- 考试管理系统 - C#源码
- Asp.net学生信息管理系统源码
- asp.net C#购物车源代码
- C#实时网络流量监听源码
- ASP.NET实验室预约管理系统
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 020ASP.NET车辆综合管理系统.zip
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
川公网安备 51152502000135号
评论
共有 条评论