国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

從一個輿論調查的制作談面向對象的編程思路(五)

2024-07-21 02:16:41
字體:
來源:轉載
供稿:網友
好了,現在萬事俱備,只欠東風了,讓我們看看現在做一個輿論調查多么簡單:

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分鐘內把你所需要的輿論調查做出來?這就是這兩種編程方法最大的區別。希望通過這個例子你能學到一些編程思想把。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 镇沅| 城口县| 明星| 黑龙江省| 娄底市| 金坛市| 丽水市| 扎鲁特旗| 左贡县| 荣成市| 丽水市| 安达市| 增城市| 石楼县| 乐都县| 南京市| 大洼县| 友谊县| 永康市| 鄂尔多斯市| 绥滨县| 盘山县| 昭平县| 蓬溪县| 咸丰县| 凤庆县| 吉安县| 砚山县| 青冈县| 东阿县| 沙洋县| 安龙县| 郓城县| 高淳县| 昌都县| 东方市| 正宁县| 望都县| 苗栗县| 石景山区| 车致|