站长首页  新闻资讯  网站运营  网站源码  站长学院  赚钱联盟  站长论坛  链接交换  素材中心  站长工具
设为主页
收藏本站
寻找帮助
 学院首页 | 网络编程 | 网页设计 | 图形图象 | 数 据 库 | 服务器技术 | 网络安全 | 网络媒体 | 搜索排名 | 网站运营 |
 当前位置:站长前线 >> 站长学院 >> 网络编程 >> .NET教程 >> 从一个舆论调查的制作谈面向对象的编程思路(五)
∷ 相关文章 ∷
从一个舆论调查的制作谈面..
从一个舆论调查的制作谈面..
从一个舆论调查的制作谈面..
从一个舆论调查的制作谈面..
从一个舆论调查的制作谈面..
∷ 热门文章 ∷
网吧生存手册:10秒钟还你..
密码攻防实战:驱动器隐藏..
木马入侵手段及防范措施
PhotoShop 学习方法论简单..
ASP.NET下MVC设计模式的实..
使用Win2003搭建视频服务器..
asp.net StreamReader 创建..
代理商之痛(转互联网大会..
Linux 服务器的安全隐患以..
用VB实现一个简单的ESMTP客..
 
从一个舆论调查的制作谈面向对象的编程思路(五)
作者:未知   来源:CSDN   发布日期:2004-6-28   点击次数: 507
从一个舆论调查的制作谈面向对象的编程思路(五)
好了,现在万事俱备,只欠东风了,让我们看看现在做一个舆论调查多么简单:

file : vote.aspx


<%@ Page language="c#" Codebehind="vote.cs" AutoEventWireup="false" Inherits="Football.vote" %>

<html>
<head>
<title>532.com.cn --- 舆论调查 ---</title>
<link rel="stylesheet" href="style/style.css" type="text/css">

</head>
<body>

<form method="post" runat="server">
<table width=400 height=300 align=center>
<tr>
<td class=cn valign=top align=center><b>调查题目:
<asp:label id="lblSurveyTitle" runat=Server class=cn></asp:label>
</td>
</tr>
<tr>
<td alin=center>
<asp:image id="imgSurvey" runat=Server></asp:image>
</td>
</tr>
<tr>
<td align=center>
<input type=button onclick="window.close();" value="关闭此窗口">
</td>
</tr>
</table>
</form>

</body>
</html>

file: vote.cs
namespace Football
{
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;

/// <summary>
/// Summary description for vote.
/// </summary>
public class vote : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Image imgSurvey;
protected System.Web.UI.WebControls.Label lblSurveyTitle;

private string m_strSurveyID ;
private int m_intVoteID ;
public vote()
{
Page.Init += new System.EventHandler(Page_Init);
}

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//
// Evals true first time browser hits the page
//
}
}

protected void Page_Init(object sender, EventArgs e)
{
//
// CODEGEN: This call is required by the ASP+ Windows Form Designer.
//
InitializeComponent();
Init() ;
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler (this.Page_Load);
}

private void Init()
{
m_strSurveyID = Request["surveyid"].ToString() ;
FootballSurvey mySurvey = new FootballSurvey() ;

try
{
m_intVoteID = Request["vote"].ToInt32() ;
mySurvey.LoadFromDatabase(m_strSurveyID) ;
lblSurveyTitle.Text = mySurvey.Title ;
if (m_intVoteID < mySurvey.Items.Count)
{
mySurvey.Vote(m_intVoteID) ;
}

mySurvey.CreateResultImage(Server.MapPath("survey.jpg") ,
MyClass.Util.MyChart.ChartType.Pie ,
300 ,300 , Color.White) ;
imgSurvey.ImageUrl = "survey.jpg" ;
}
catch(Exception e)
{
#if DEBUG
Response.Write ("初始化页面错误:" + e.ToString()) ;
return ;
#endif
Page.Navigate("error.aspx") ;
}

}
}
}

要看这个调查的效果,请到http://210.12.102.95/football 。怎么样,是不是觉得这种编程思路不错呢?什么?还不如直接在aspx文件里面做?不错,如果单做这么一个调查的确直接做要省事的多,但你知不知道,只要有编译好的这个类的dll,不管你怎么改页面,改数据结构,你都可以在15分钟内把你所需要的舆论调查做出来?这就是这两种编程方法最大的区别。希望通过这个例子你能学到一些编程思想把。


[告诉好友] [关闭窗口] [返回上一页] [打 印]

  • 上篇文章:c#写的五子棋程序,供学习WinForms的鼠标事件和使用GDI+
  • 下篇文章:从一个舆论调查的制作谈面向对象的编程思路(四)
  • 关于本站 版权申明 广告服务 友情链接 寻找帮助 联系我们 人才招聘
    Copyright © 2002-2006 Zzadmin.Com. All Rights Reserved .
    Powered by:Zzadmin.com
    本站资源搜集于网络与本站无关如有侵权请来信指出!