ASP编程 PHP编程 JSP编程 NET编程 CGI编程 XML编程 
Google adsense申请技巧本站核心代理域名注册主机业务 快速发布你的买卖域名买卖网站信息 1元注册 cn域名
站长每日新闻导读 √ ·推荐万网空间¥120元 150m 站长网:站长必上的网站网站联盟大全本站代理万网域名55空间120元
 2006-12-10 10:15:15

WebPoll in C#[Vs.net Bate2 等级:中 高]

来源: 字体:[ ]
WebPoll in C# is implemented as a User Control in a Vs.Net  Beta2 project. The database behind the control is SQL Server, but it could easily be moved to Access. I needed a WebPoll for my site, saw one done on AspToday in VBScript for regular ASP. I made a few modifications and converted the project to .Net and C#.  A working copy of the WebPoll can be viewed at http://72t.net (what I really do in life) or at http://Dn.yyyz.net (the initial conversion of my personal site).  

As you play, please send me any changes and suggestions for improving the code - I'm still learning both .Net and C#.  If you implement the poll on your site, you should probably use at least two answers to each question - a one question poll doesn't make much sense. The number of answers isn't limited - enter as many as you like. Using different Poll IDs, you can have multiple polls running on the same site at the same time.

Things to look for in the code:

Construction of a table with rows and cells in the C# code behind page.
Adding Radio Buttons and text to individual table cells.
Implementing a Submit Button and handler from the code behind page.
Stepping through a group of Radio Buttons to query for the checked button.
Use of Cookies to overcome multiple answers from the same computer.
Use of Classes for both the Question and Answers
Main Files:

Default.aspx - a page used to implement the control. The control is registered. Two items, the Poll Id and the connection string are passed to the WebPoll control
WebPoll.ascx - the html portion of the control. This page only has a PlaceHolder control that is used as a place holder. All the code (tables, etc.) are constructed in the code behind class.
WebPoll.ascx.cs - the code behind class - the control is built entirely in the .cs code behind page. Look through the actual page for comments and explanation. It builds two tables, one to ask the questions and one to show the results.
WebPoll.sql - the SQL Query file (created by SQL 2000) that will create the tables used by the WebPoll control - Questions go in  'PollQuestions' table and the answers go in the 'PollAnswers '.
WebPoll.htm - this page
Possible Improvements (if you make any, please let me know) :

A user interface that could be used to add or delete questions - in this version, you have to enter the items into the database tables manually.
A button that would allow viewing the results of previous polls.
Converting the existing UserControl to a full web control.
Sourc


网站地图 - 域名注册续费虚拟主机代理 - 交易论坛 - 网站投稿 - 广告服务 - 帮助中心 - 联系我们
Copyright ©2003-2007 www.Admin5.com All Rights Reserved