看了http://dev.csdn.net/里右侧的投票饼图,觉得挺有趣的,


所以就自己也模仿了一个..演示页面:http://www.conanlwl.net/bbspic/TestVote.aspx


具体步骤如下..(C#)
本例子中利用XML文件来保存投票数据.XML文件格式如下,文件名称为Vote.XML
<?xml version="1.0" encoding="utf-8"?>
<Vote>
<VoteInfo>
<ID>1</ID>
<VoteTitle>以下三国人物你喜欢谁?</VoteTitle>
<Item>
<VoteID>1</VoteID>
<Title>曹操</Title>
<Count>2</Count>
</Item>
<Item>
<VoteID>2</VoteID>
<Title>刘备</Title>
<Count>2</Count>
</Item>
<Item>
<VoteID>3</VoteID>
<Title>孙权</Title>
<Count>2</Count>
</Item>
<Item>
<VoteID>4</VoteID>
<Title>司马懿</Title>
<Count>2</Count>
</Item>
<Item>
<VoteID>5</VoteID>
<Title>诸葛亮</Title>
<Count>1</Count>
</Item>
<Item>
<VoteID>6</VoteID>
<Title>陆逊</Title>
<Count>1</Count>
</Item>
<Item>
<VoteID>7</VoteID>
<Title>吕布</Title>
<Count>1</Count>
</Item>
<Item>
<VoteID>8</VoteID>
<Title>姜维</Title>
<Count>1</Count>
</Item>
<Item>
<VoteID>9</VoteID>
<Title>其它</Title>
<Count>2</Count>
</Item>
</VoteInfo>
</Vote>
第一步,就是投票页面了,我们就通过这个页面来进行对选项的投票.新建一个WebForm,并命名为TestVote.aspx
<HTML>
<HEAD>
<title>模仿CSDN的投票结果</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<fieldset style="WIDTH:20%;float:left">
<legend accesskey="F" style="FONT-WEIGHT:bold;COLOR:#000000;font-size:12px" align=center>
<%=VoteTitle%></legend>
<ul style="list-style-type:none;margin-left:50px">
>
以下是testvote.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.Xml;

namespace BbsPic
第二步,就是我们的饼图图片页面,最后以二进制流的方式显示出来..本饼图有两种状态,一是没被点中时的全圆饼图,第二就是当某个选项被点中时分离出来的饼图.新建一WebForm窗体,命名为Vote.aspx
在Vote.aspx里把除了<%page ....%>以外的HTML代码全部删掉.
接着是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.Xml;

namespace BbsPic
第三步,因为要使图片里的饼图的某个选项能够点击,就必须要由另外一个页面来装载这个图片,并在图片上描绘热点.所以就必须新建一个窗体,这个窗体也是"显示投票结果"的显示页面.
新建一个WebForm窗体,并命名为ShowVote.aspx
以下是ShowVote.aspx的HTML代码:
<HTML>
<HEAD>
<title>查看投票结果</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body topmargin=0 leftmargin=0>
<img src="Vote.Aspx?i=<%=Request.QueryString["i"]%>&voteid=<%=Request.QueryString["voteid"]%>" USEMAP="#Map" border=0>
<MAP NAME="Map">
<%=Map%>
</map>
</body>
</HTML>
以下是ShowVote.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.Xml;

namespace BbsPic
转自: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1604941