欢迎光临
我们一直在努力

WebPoll in C#[Vs.net Bate2 等级:中 高]-.NET教程,Asp.Net开发

建站超值云服务器,限时71元/月

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 – im 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 doesnt make much sense. the number of answers isnt 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.
source code

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » WebPoll in C#[Vs.net Bate2 等级:中 高]-.NET教程,Asp.Net开发
分享到: 更多 (0)

相关推荐

  • 暂无文章