posts - 56,  comments - 12,  trackbacks - 0

          /*CalendarForm2.aspx

          前臺程序

          */

          <%@ Page language="c#" Codebehind="CalendarForm2.aspx.cs" AutoEventWireup="false" Inherits="CalendarDemo.CalendarForm2" %>
          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
          <HTML>
           <HEAD>
            <title>CalendarForm2</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=" </HEAD>
           <body MS_POSITIONING="GridLayout">
            <form id="Form1" method="post" runat="server">
             <FONT face="宋體">
              <asp:ListBox id="lbxEmployee" style="Z-INDEX: 101; LEFT: 224px; POSITION: absolute; TOP: 80px"
               runat="server" Width="144px" Height="264px" Rows="7" AutoPostBack="True"></asp:ListBox>
              <asp:Calendar id="calHire" style="Z-INDEX: 102; LEFT: 232px; POSITION: absolute; TOP: 384px" runat="server"
               Width="312px" Height="160px"></asp:Calendar>
              <asp:Label id="lblInfo" style="Z-INDEX: 103; LEFT: 232px; POSITION: absolute; TOP: 352px" runat="server"
               Width="152px" Height="24px">display Dates</asp:Label></FONT>
            </form>
           </body>
          </HTML>

          /*CalendarForm2.aspx.cs

          日歷控件使用后臺程序

          */

          using System;
          using System.Collections;
          using System.ComponentModel;
          using System.Data;
          using System.Data.SqlClient;
          using System.Drawing;
          using System.Web;
          using System.Web.SessionState;
          using System.Web.UI;
          using System.Web.UI.WebControls;
          using System.Web.UI.HtmlControls;

          namespace CalendarDemo
          {
           /// <summary>
           /// CalendarForm2 的摘要說明。
           /// </summary>
           public class CalendarForm2 : System.Web.UI.Page
           {
            protected System.Web.UI.WebControls.ListBox lbxEmployee;
            protected System.Web.UI.WebControls.Calendar calHire;
            protected System.Web.UI.WebControls.Label lblInfo;
           
            private void Page_Load(object sender, System.EventArgs e)
            {
             // 在此處放置用戶代碼以初始化頁面
             string strCon="server=JOSEN;database=NorthWind;integrated security=true";
             string strSql="select EmployeeID,LastName,FirstName,HireDate from Employees";

             SqlConnection objCon=new SqlConnection(strCon);
             SqlDataAdapter objAdpt=new SqlDataAdapter(strSql,objCon);

             DataSet ds=new DataSet();
             objAdpt.Fill(ds,"dtEmployee");

             if(!IsPostBack)
             {
              this.lbxEmployee.DataSource=ds;
              lbxEmployee.DataTextField="LastName";
              lbxEmployee.DataBind();
             }
             else
             {
              DateTime datHireDate;
              datHireDate=Convert.ToDateTime(ds.Tables["dtEmployee"].Rows[lbxEmployee.SelectedIndex]["HireDate"]);

              lblInfo.Text=ds.Tables["dtEmployee"].Rows[lbxEmployee.SelectedIndex]["LastName"].ToString();

              this.calHire.VisibleDate=datHireDate;
              calHire.SelectedDate=datHireDate;
              lblInfo.Text+="hired on "+datHireDate;
             }
            }

            #region Web 窗體設計器生成的代碼
            override protected void OnInit(EventArgs e)
            {
             //
             // CODEGEN: 該調(diào)用是 ASP.NET Web 窗體設計器所必需的。
             //
             InitializeComponent();
             base.OnInit(e);
            }
            
            /// <summary>
            /// 設計器支持所需的方法 - 不要使用代碼編輯器修改
            /// 此方法的內(nèi)容。
            /// </summary>
            private void InitializeComponent()
            {   
             this.Load += new System.EventHandler(this.Page_Load);

            }
            #endregion
           }
          }

           


          苦笑枯 2007-01-19 00:15 發(fā)表評論

          文章來源:http://www.aygfsteel.com/kuxiaoku/articles/94808.html
          posted on 2007-01-19 00:15 苦笑枯 閱讀(227) 評論(0)  編輯  收藏 所屬分類: C#
          收藏來自互聯(lián)網(wǎng),僅供學習。若有侵權(quán),請與我聯(lián)系!

          <2007年1月>
          31123456
          78910111213
          14151617181920
          21222324252627
          28293031123
          45678910

          常用鏈接

          留言簿(2)

          隨筆分類(56)

          隨筆檔案(56)

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 禹州市| 年辖:市辖区| 平武县| 巴彦淖尔市| 竹溪县| 西华县| 岢岚县| 会泽县| 修水县| 沙坪坝区| 泾川县| 锡林浩特市| 广汉市| 保定市| 苏州市| 阜平县| 新营市| 皋兰县| 神农架林区| 都昌县| 朝阳县| 民乐县| 兰溪市| 彭水| 桓台县| 宁海县| 台江县| 塔河县| 万全县| 莱芜市| 桓台县| 金川县| 汽车| 镇远县| 五原县| 永嘉县| 梁山县| 万州区| 灌阳县| 兴仁县| 常德市|