C_網(wǎng)頁控件課程設(shè)計(jì)--BS控件應(yīng)用_第1頁
C_網(wǎng)頁控件課程設(shè)計(jì)--BS控件應(yīng)用_第2頁
C_網(wǎng)頁控件課程設(shè)計(jì)--BS控件應(yīng)用_第3頁
C_網(wǎng)頁控件課程設(shè)計(jì)--BS控件應(yīng)用_第4頁
C_網(wǎng)頁控件課程設(shè)計(jì)--BS控件應(yīng)用_第5頁
已閱讀5頁,還剩5頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、;. C#網(wǎng)絡(luò)編程技術(shù)綜合實(shí)驗(yàn)報(bào)告三題目: B/S控件應(yīng)用 院(系): 專業(yè)班級: 學(xué) 號: 學(xué)生姓名: 指導(dǎo)教師: 教師職稱: 起止時(shí)間: B/S控件應(yīng)用一、 問題描述本課程設(shè)計(jì)的目的是鍛煉學(xué)生熟練掌握簡單的C#窗體和控件的設(shè)計(jì)。使之能夠應(yīng)用Visual Studio 程序軟件熟練進(jìn)行web窗體小項(xiàng)目的編輯。希望通過本次練習(xí)提高學(xué)生使用C#語言控件解決實(shí)際問題的能力。二、 問題分析1、需要實(shí)現(xiàn)的系統(tǒng)目標(biāo)a)通過Visual Studio程序軟件,結(jié)合所學(xué)內(nèi)容,進(jìn)行C#程序web控件的編寫;b)所有控件最終設(shè)計(jì)要達(dá)成之前預(yù)計(jì)實(shí)現(xiàn)的各項(xiàng)功能;c)在功能實(shí)現(xiàn)的基礎(chǔ)上,力求程序控件界面美觀得體;d)

2、 練習(xí)簡單應(yīng)用程序開發(fā)設(shè)計(jì)及程序開發(fā)方法。F) 通過所學(xué)知識,盡量在控件中添加更多功能。2、需要實(shí)現(xiàn)的功能需求 通過CheckBox控件,實(shí)現(xiàn)事務(wù)單項(xiàng)選擇功能,并在TextBox中顯示所選內(nèi)容。 實(shí)現(xiàn)CheckBoxList選項(xiàng)列表功能。 實(shí)現(xiàn)CheckedListBox復(fù)選框的多選內(nèi)容,按鈕單擊顯示 實(shí)現(xiàn)RadioButton單項(xiàng)選擇框的任意選擇,通過Web網(wǎng)頁顯示所選的內(nèi)容。 編輯RadioButtonList控件,確定選擇之后,在網(wǎng)頁中顯示所選內(nèi)容。 進(jìn)行ListBox插入信息在相應(yīng)文本框中輸出,并可進(jìn)行相應(yīng)的插入、刪除操作。 實(shí)現(xiàn)DropDownList中下拉選擇確定功能。 完成Tab

3、le控件顯示的網(wǎng)格線模式,處理表格中信息。 通過相應(yīng)程序,完成通過網(wǎng)頁瀏覽相關(guān)文本,并上傳此信息至服務(wù)器。 完成Table控件在設(shè)計(jì)模式下向表格添加文本或控件。 掌握Web窗體設(shè)計(jì)模式與HTML模式的聯(lián)合使用。 熟練在代碼隱藏類中編寫HTML及客戶端腳本的方法。3、實(shí)驗(yàn)環(huán)境(本次上機(jī)實(shí)驗(yàn)所使用的平臺和相關(guān)軟件) Windows Xp 系統(tǒng) + Visual Studio 2005 程序軟件三、 程序設(shè)計(jì) 根據(jù)所需內(nèi)容,按要求在WindowsApplication中添加ASP.NET Web控件。 選擇工具箱,按需求選擇窗體控件添加,如圖, 控件名稱圖2-1 用于多選框選擇文字輸入,CheckB

4、ox控件 圖2-2 RadioButton控件所實(shí)現(xiàn)的單項(xiàng)選擇功能圖2-3 RadioButtonList選擇框及其效果圖2-4 ListBox控件,實(shí)現(xiàn)向列表框中插入和刪除信息功能 圖2-5 DropDownList控件,實(shí)現(xiàn)下拉菜單選擇功能圖2-6 Table控件,運(yùn)行結(jié)果如圖圖2-7 File Field控件,實(shí)現(xiàn)選擇上傳文件功能 為每個(gè)控件添加所需的程序 編輯完畢,運(yùn)行程序,效果如圖:四、 程序?qū)崿F(xiàn)using System;using System.Collections;using System.ComponentModel;using System.Data;using Syste

5、m.Drawing;using System.Web;using System.Web.SessionState;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.HtmlControls;namespace _123/ <summary>/ WebForm1 的摘要說明。/ </summary>public class WebForm1 : System.Web.UI.Pageprivate void Page_Load(object sender, System.Event

6、Args e)if(!Page.IsPostBack)ListItem stra= new ListItem("操作系統(tǒng)"),new ListItem("數(shù)據(jù)結(jié)構(gòu)"),new ListItem("數(shù)據(jù)庫");DropDownList1.Items.AddRange(stra);if(!Page.IsPostBack)ListItem item=new ListItem10;for(int i=0;i<item.Length;i+)itemi=new ListItem("選項(xiàng)"+i.ToString();Che

7、ckBoxList1.Items.AddRange(item);#region Web 窗體設(shè)計(jì)器生成的代碼override protected void OnInit(EventArgs e)/ CODEGEN: 該調(diào)用是 ASP.NET Web 窗體設(shè)計(jì)器所必需的。InitializeComponent();base.OnInit(e);/ <summary>/ 設(shè)計(jì)器支持所需的方法 - 不要使用代碼編輯器修改/ 此方法的內(nèi)容。/ </summary>private void InitializeComponent() this.Button1.Click += n

8、ew System.EventHandler(this.Button1_Click);this.TextBox1.TextChanged += new System.EventHandler(this.TextBox1_TextChanged);this.Button2.Click += new System.EventHandler(this.Button2_Click);this.Button3.Click += new System.EventHandler(this.Button3_Click);this.Button4.Click += new System.EventHandler

9、(this.Button4_Click);this.Button5.Click += new System.EventHandler(this.Button5_Click);this.Button6.Click += new System.EventHandler(this.Button6_Click);this.Button7.Click += new System.EventHandler(this.Button7_Click);this.Button8.Click += new System.EventHandler(this.Button8_Click);this.Button9.Cl

10、ick += new System.EventHandler(this.Button9_Click);this.Load += new System.EventHandler(this.Page_Load);#endregionprivate void Button1_Click(object sender, System.EventArgs e)Response.Write("<script>window.confirm('ok?');</script>");private void TextBox1_TextChanged(obj

11、ect sender, System.EventArgs e)Response.Write("<script>window.alert('"+this.TextBox1.Text+"')</script>");private void Button2_Click(object sender, System.EventArgs e)string str="選擇結(jié)果:"if(CheckBox1.Checked=true) str+=CheckBox1.Text+"、"if(Che

12、ckBox2.Checked=true) str+=CheckBox2.Text+"、"if(CheckBox3.Checked=true) str+=CheckBox3.Text+"、"if(strstr.Length-1='、') str=str.Substring(0,str.Length-1);TextBox2.Text=str;private void Button3_Click(object sender, System.EventArgs e)string str="選擇結(jié)果:"for(int i=0;i

13、<CheckBoxList1.Items.Count;i+)if(CheckBoxList1.Itemsi.Selected)str+=CheckBoxList1.Itemsi.Text+"、"if(strstr.Length-1='、') str=str.Substring(0,str.Length-1);Response.Write("<script>window.alert('"+str+"');</script>");Response.Write("<

14、;script>window.alert('"+this.TextBox1.Text+"')</script>");private void Button4_Click(object sender, System.EventArgs e)string str="你選擇的是:"if(RadioButton1.Checked)str+=RadioButton1.Text;else if(RadioButton2.Checked)str+=RadioButton2.Text;else if(RadioButton3.

15、Checked)str+=RadioButton3.Text;Response.Write("<script>window.alert('"+str+"')</script>");private void Button5_Click(object sender, System.EventArgs e)string str="你選擇的是:"if(RadioButtonList1.SelectedIndex>-1)str+=RadioButtonList1.SelectedItem.Text;

16、Response.Write("<script>window.alert('"+str+"')</script>");private void Button6_Click(object sender, System.EventArgs e)/插入非重復(fù)條目bool ifExist=false;if (TextBox3.Text!="") /for語句用來查找是否有重復(fù)條目,ListBox1.Items.Count代表列表框中/條目的個(gè)數(shù)for(int i=0;i<ListBox1.Item

17、s.Count;i+)if(ListBox1.Itemsi.ToString()=TextBox3.Text)ifExist=true;/找到時(shí)中斷退出break;if(!ifExist)ListBox1.Items.Add(TextBox3.Text);private void Button7_Click(object sender, System.EventArgs e)for(int i=ListBox1.Items.Count-1;i>=0;i-)if(ListBox1.Itemsi.Selected)ListBox1.Items.Remove(this.ListBox1.Ite

18、msi);private void Button8_Click(object sender, System.EventArgs e)Table1.Rows.Clear();AddRow("搜狐企業(yè)在線","","包括招商引資、企業(yè)報(bào)道等信息。");AddRow("263在線","","包括娛樂、生活、旅游等信息。");private void AddRow(string str1,string url,string str2)TableRow row=new TableRow

19、();HyperLink hyperlink=new HyperLink();hyperlink.Text=str1;hyperlink.NavigateUrl=url;hyperlink.Target="_top"TableCell cell1=new TableCell();cell1.Font.Size=FontUnit.XSmall;cell1.Controls.Add(hyperlink);row.Cells.Add(cell1);TableCell cell2=new TableCell();cell2.Font.Size=FontUnit.XSmall;cell2.ForeColor=Color.Blue;cell2.Text=str2;row.Cells.Add(cell2);Table1.Rows.Add(row);private void B

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論