NET編程操作實(shí)務(wù)程形成性考核冊復(fù)習(xí)資料解讀_第1頁
NET編程操作實(shí)務(wù)程形成性考核冊復(fù)習(xí)資料解讀_第2頁
NET編程操作實(shí)務(wù)程形成性考核冊復(fù)習(xí)資料解讀_第3頁
NET編程操作實(shí)務(wù)程形成性考核冊復(fù)習(xí)資料解讀_第4頁
NET編程操作實(shí)務(wù)程形成性考核冊復(fù)習(xí)資料解讀_第5頁
已閱讀5頁,還剩8頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

.NET編程操作實(shí)務(wù)程形成性考核冊答案第1次作業(yè)1、一個項目,要求在一個頁面里同時使用HtmlImage控件與一個HtmlSelect控件,當(dāng)點(diǎn)擊HtmlSelect控件中不同的文件名時,Html控件顯示不同的圖片。步驟:頁面中創(chuàng)建HtmlImage控件與HtmlSelect控件設(shè)置控件的相關(guān)屬性,為控件添加方法聲明相應(yīng)的方法,實(shí)現(xiàn)對應(yīng)的效果關(guān)鍵代碼:<scripttype=”text/javascript”>建立functionSlt_change(){varva=document.getElementById(“Select1”).value;switch(va){case“01”:document.getElementById(“img1”).src=“”;break;case“02”:document.getElementById(“img1”).src=“”;break;case“03”:document.getElementById(“img1”).src=“”;break;}}</script><body><h3>Select控?制?Image圖a?像?顯?示o?</h3><formid=”form1”runat=”server”><imgid=”img1”runat=”server”src=””alt=”圖像加載不了”/><selectid="Select1"runat="server"onchange="Slt_change()"class="Select1"><optionvalue="01">01.jpg</option><optionvalue="02">02.jpg</option><optionvalue="03">03.jpg</option></select></form></body>2、建立一個項目,要求在一個頁面里同時使用HtmlInputImage控件與Span控件,當(dāng)單機(jī)HtmlInputImage控件的圖像時,Span控件顯示圖像已被單擊。步驟:頁面中創(chuàng)建HtmlInputImage控件與Span控件設(shè)置控件的相關(guān)屬性,為控件添加方法聲明相應(yīng)的方法,實(shí)現(xiàn)對應(yīng)的效果關(guān)鍵代碼:<scriptlanguage="C#"runat="server">voidimg_btn(objectSource,EventArgse){span1.Visible=true;}</script><formid="form1"runat="server"><inputtype="image"id="img1"runat="server"src="img/01.jpg"onserverclick="img_btn"/><br/><spanid="span1"runat="server"visible="false">圖像已被點(diǎn)擊</span></form>3、建立一個項目,要求在一個頁面里同時使用HtmlInputPassword控件與Submit控件,以在頁面里顯示一個密碼框與提交按鈕。步驟:頁面中創(chuàng)建HtmlInputPassword控件與Submit控件設(shè)置控件的相關(guān)屬性關(guān)鍵代碼:<formid="form1"runat="server"> <inputid="Password1"type="password"/><inputid="Submit1"type="submit"value="登陸"/></form>4、建立一個項目要求在一個頁面里使用HtmlInputRadioButton控件顯示兩個有互斥特性的單選按鈕,然后再在頁面里放入一個HtmlButton控件與一個Span控件,當(dāng)單擊HtmlButton控件時Span控件顯示選中的是哪個單選按鈕。步驟:頁面中創(chuàng)建HtmlInputRadioButton控件、HtmlButton控件與Span控件設(shè)置控件的相關(guān)屬性,使兩個單選按鈕為一組為HtmlButton按鈕添加方法聲明相應(yīng)的方法,實(shí)現(xiàn)對應(yīng)的效果關(guān)鍵代碼:<scriptlanguage="C#"runat="server">voidbtn_click(objectSource,EventArgse){if(Radio1.Checked==true){Span1.InnerHtml="被選中的是男性";}elseif(Radio2.Checked==true){Span1.InnerHtml="被選中的是女性";}}</script><formid="form1"runat="server"><inputid="Radio1"name="Radio"type="radio"runat="server"/>男<br/><inputid="Radio2"name="Radio"type="radio"runat="server"/>女<br/><inputid="Button1"type="button"runat="server"value="查看選中的性別"onserverclick="btn_click"/><br/><spanid="Span1"runat="server"></span></form>第2次作業(yè)1、建立一個項目,要求使用AdRotator控件在頁面中顯示一張產(chǎn)品圖像廣告,單擊圖像后,能打開一個新頁面。步驟:創(chuàng)建AdRotator控件、Ads頁面與jianjie.aspx頁面設(shè)置控件的相關(guān)屬性完善Ads頁面代碼與jianjie.jspx頁面代碼關(guān)鍵代碼:AdRotator.jspx代碼:<formid="form1"runat="server"><asp:AdRotatorID="AdRotator1"runat="server"AdvertisementFile="~/ads.xml"BorderWidth="1px"/></form>Ads.xml代碼:<Advertisements><Ad><ImageUrl>img/cup.jpg</ImageUrl><NavigateUrl>jianjie.aspx</NavigateUrl><AlternateText>

物品簡介</AlternateText><Keyword>favorites</Keyword><Impressions>20</Impressions></Ad></Advertisements>jianjie.jspx代碼:<formid="form1"runat="server"><div>這是一個咖啡杯</div></form>2、建立一個項目,要求在頁面中使用CheckBoxList控件與按鈕實(shí)現(xiàn)全選與反選。步驟:頁面中插入CheckBoxList控件與Button按鈕設(shè)置控件的相關(guān)屬性,為控件添加方法聲明相應(yīng)的方法,實(shí)現(xiàn)對應(yīng)的效果關(guān)鍵代碼:<scriptlanguage="C#"runat="server">voidall_click(objecto,EventArgse){for(inti=0;i<CheckBoxList1.Items.Count;i++){CheckBoxList1.Items[i].Selected=true;}}voidelse_click(objecto,EventArgse){for(inti=0;i<CheckBoxList1.Items.Count;i++){if(CheckBoxList1.Items[i].Selected==true){CheckBoxList1.Items[i].Selected=false;}else{CheckBoxList1.Items[i].Selected=true;}}}</script><formid="form1"runat="server"><asp:CheckBoxListID="CheckBoxList1"runat="server"><asp:ListItem>游泳</asp:ListItem><asp:ListItem>爬山</asp:ListItem><asp:ListItem>上網(wǎng)</asp:ListItem><asp:ListItem>學(xué)習(xí)</asp:ListItem><asp:ListItem>睡覺</asp:ListItem><asp:ListItem>跑步</asp:ListItem></asp:CheckBoxList><br/><asp:ButtonID="Button1"runat="server"Text="全選"OnClick="all_click"/><asp:ButtonID="Button2"runat="server"Text="反選"OnClick="else_click"/><br/></form>3、建立一個項目,要求在頁面中使用Calendar控件與Label控件,當(dāng)單擊Calendar控件中的某個日期后,Label控件顯示相應(yīng)的日期。步驟:頁面中插入Calendar控件與Label控件設(shè)置Calendar控件的相關(guān)屬性,為其添加方法聲明相應(yīng)的方法,實(shí)現(xiàn)對應(yīng)的效果關(guān)鍵代碼:<scriptlanguage="C#"runat="server">voidchange(objecto,EventArgse){Label1.Text=Calendar1.SelectedDate.ToShortDateString();}</script><formid="form1"runat="server"> <asp:CalendarID="Calendar1"runat="server"OnSelectionChanged="change"></asp:Calendar> <asp:LabelID="Label1"runat="server"Text="Label"></asp:Label></form>4、創(chuàng)建一個項目,要求在頁面中使用DropDownList控件、Label控件與Button控件,當(dāng)單擊Button控件后,Label控件顯示DropDownList控件中的選中文本。步驟:頁面中添加DropDownList控件、Label控件與Button控件設(shè)置控件的相關(guān)屬性,為控件添加方法聲明相應(yīng)的方法,實(shí)現(xiàn)對應(yīng)的效果關(guān)鍵代碼:<scriptlanguage="C#"runat="server">voidselect(objecto,EventArgse){Label1.Text=DropDownList1.SelectedItem.Text;}</script><formid="form1"runat="server"><asp:DropDownListID="DropDownList1"runat="server"><asp:ListItem>北京</asp:ListItem><asp:ListItem>上海</asp:ListItem><asp:ListItem>廣州</asp:ListItem><asp:ListItem>大連</asp:ListItem><asp:ListItem>香港</asp:ListItem></asp:DropDownList><asp:ButtonID="Button1"runat="server"Text="你的選擇是:"OnClick="select"/><asp:LabelID="Label1"runat="server"Text="Label"></asp:Label></form>第3次作業(yè)1、建立一個項目,要求用Login控件、LoginView控件與SQLServer2008軟件實(shí)現(xiàn)向匿名用戶與注冊用戶顯示不同的信息。步驟:修改web.config文件,將登陸頁面設(shè)為,配置數(shù)據(jù)庫連接并添加Login控件關(guān)鍵代碼:Web.aspx代碼:<formsloginUrl="login.aspx"timeout="2880"/><connectionStrings> <removename="LocalSqlServer"/> <addname="LocalSqlServer"connectionString="DataSource=LIU\MYSERVER2008;InitialCatalog=TestDB;Userid=sa;Password=123456"providerName="System.Data.SqlClient"/><addname="TestDB"connectionString="Server=LIU\MYServer2008;database=TestDB;uid=sa;pwd=123456"providerName="system.Data.SqlClient"/></connectionStrings>LoginViewDiffInfo.aspx代碼:<h3>用LoginView控件向匿名用戶與登陸用戶顯示不同信息</h3><asp:LoginViewID="LoginView1"runat="server"><LoggedInTemplate>這里是已登錄的模板,這里可以執(zhí)行下載或更改密碼<p></p><asp:LoginNameID="LoginName1"FormatString="歡迎回?來,{0}."runat="server"/><p></p><asp:LoginStatusID="LoginStatus1"LogoutAction="RedirectToLoginPage"runat="server"/></LoggedInTemplate>這里是非注冊用戶的模板,頁面將跳轉(zhuǎn)到登錄頁面,頁面正在跳轉(zhuǎn)中<p></p><AnonymousTemplate></AnonymousTemplate></asp:LoginView>Login.aspx代碼:<formid="form1"runat="server"><center><h3>用LoginView控件向匿名用戶與登錄用戶顯示不同信息</h3><p>請輸入登錄信息以完成登錄</p><div><asp:LoginID="Login1"runat="server"OnAuthenticate="Login1_Authenticate"DestinationPageUrl="~/LoginViewDiffInfo.aspx"BorderWidth="1"></asp:Login></div></center></form>Login.aspx.cs代碼:protectedvoidLogin1_Authenticate(objecto,AuthenticateEventArgse){inti=-1;SqlConnectionMyConn=newSqlConnection("Server=LIU\MYServer2008;database=TestDB;uid=sa;pwd=123456");SqlCommandMyCom=newSqlCommand("SELECTCOUNT(*)FROM[TESTDB].[dbo].[MYUsersTable]WHEREusername='"+Login1.UserName+"'ANDpwd='"+Login1.Password+"'",MyConn);try{MyConn.Open();i=Convert.ToInt32(MyCom.ExecuteScalar());}catch{i=-1;}finally{MyConn.Close();MyCom.Dispose();MyConn.Disposed();}if(i>=1){e.Authenticated=true;}else{e.Authenticated=false;}}2、建立一個項目,要求用Login控件、LoginName控件與SQLServer2008軟件顯示當(dāng)前登錄用戶的用戶名。步驟:修改web.config配置文件,配置數(shù)據(jù)庫連接在Login.aspx.cs文件中完善相關(guān)方法,用于用戶登錄時完成驗(yàn)證功能。關(guān)鍵代碼:配置數(shù)據(jù)庫連接 <removename="LocalSqlServer"/> <addname="LocalSqlServer"connectionString="DataSource=LIU\MYSERVER2008;InitialCatalog=TestDB;Userid=sa;Password=123456"providerName="System.Data.SqlClient"/>添加LoginName控件 <asp:LoginNameID="LoginName1"runat="server"FormatString="歡迎回來,您在本網(wǎng)站的用戶名是:{0},當(dāng)前的身份是注冊用戶"/>添加Login控件<formid="form1"runat="server"><center><asp:LoginID="Login1"runat="server"OnAuthenticate="Login1_Authernticate"DestinationPageUrl="LoginNameForNet.aspx"BorderWidth="1"></asp:Login></center></form>驗(yàn)證方法 protectedvoidPage_Load(objectsender,EventArgse){inti=-1;SqlConnectionMyConn=newSqlConnection("server=LIU\\MYServer2008;database=TestDB;uid=sa;pwd=123456");SqlCommandMyCom=newSqlCommand("SELECTCOUNT(*)FROM[TESTDB].[dbo].[MYUsersTable]WHEREusername='"+Login1.UserName+"'ANDpwd='"+Login1.Password+"'",MyConn);try{MyConn.Open();i=Convert.ToInt32(MyCom.ExecuteScalar());}catch{i=-1;}finally{MyConn.Close();MyCom.Dispose();MyConn.Dispose();if(i>=1){e.Authenticated=ture;}else{e.Authenticated=false;}}}3、建立一個項目,用Login控件、LoginName控件、LoginStatus控件與SQLServer2008軟件實(shí)現(xiàn)當(dāng)前登錄用戶的注銷或登錄。步驟:設(shè)置web.config文件,將登錄頁面設(shè)置為login.aspx,配置數(shù)據(jù)庫連接添加LoginName控件與LoginStatus控件并設(shè)置相關(guān)屬性添加Login控件并設(shè)置相關(guān)屬性設(shè)置方法,完成用戶登錄驗(yàn)證關(guān)鍵代碼:配置數(shù)據(jù)庫連接 <removename="LocalSqlServer"/> <addname="LocalSqlServer"connectionString="DataSource=LIU\MYSERVER2008;InitialCatalog=TestDB;Userid=sa;Password=123456"providerName="System.Data.SqlClient"/>添加LoginName控件 <asp:LoginNameID="LoginName1"runat="server"FormatString="歡迎回來,{0}."/>添加LoginStatus控件<asp:LoginStatusID="LoginStatus1"runat="server"LogoutAction="RedirectToLoginPage"/>添加Login控件<asp:LoginID="Login1"runat="server"OnAuthenticate="Login1_Authernticate"DestinationPageUrl="LoginNameForNet.aspx"BorderWidth="1"></asp:Login>驗(yàn)證方法 protectedvoidLogin1_Authenticate(objectsender,EventArgse){inti=-1;SqlConnectionMyConn=newSqlConnection("server=LIU\\MYServer2008;database=TestDB;uid=sa;pwd=123456");SqlCommandMyCom=newSqlCommand("SELECTCOUNT(*)FROM[TESTDB].[dbo].[MYUsersTable]WHEREusername='"+Login1.UserName+"'ANDpwd='"+Login1.Password+"'",MyConn);try{MyConn.Open();i=Convert.ToInt32(MyCom.ExecuteScalar());}catch{i=-1;}finally{MyConn.Close();MyCom.Dispose();MyConn.Dispose();if(i>=1){e.Authenticated=ture;}else{e.Authenticated=false;}}}4、建立一個項目,要求用Login控件與SQLServer2008軟件驗(yàn)證用戶登錄。步驟:設(shè)置Web.config文件,配置數(shù)據(jù)庫連接添加Login控件,設(shè)置相關(guān)屬性設(shè)置方法完成用戶登錄驗(yàn)證關(guān)鍵代碼:配置數(shù)據(jù)庫連接<removename="LocalSqlServer"/> <addname="LocalSqlServer"connectionString="DataSource=LIU\MYSERVER2008;InitialCatalog=TestDB;Userid=sa;Password=123456"providerName="System.Data.SqlClient"/>添加Login控件<asp:LoginID="Login1"runat="server"OnAuthenticate="Login1_Authernticate"DestinationPageUrl="LoginCreatePage.aspx"BorderWidth="1"></asp:Login>驗(yàn)證方法 protectedvoidLogin1_Authenticate(objectsender,EventArgse){inti=-1;SqlConnectionMyConn=newSqlConnection("server=LIU\\MYServer2008;database=TestDB;uid=sa;pwd=123456");SqlCommandMyCom=newSqlCommand("SELECTCOUNT(*)FROM[TESTDB].[dbo].[MYUsersTable]WHEREusername='"+Login1.UserName+"'ANDpwd='"+Login1.Password+"'",MyConn);try{MyConn.Open();i=Convert.ToInt32(MyCom.ExecuteScalar());}catch{i=-1;}finally{MyConn.Close();MyCom.Dispose();MyConn.Dispose();if(i>=1){e.Authenticated=ture;}else{e.Authenticated=false;}}}第4次作業(yè)1、建立一個項目,要求用RequiredFieldValidator控件驗(yàn)證用戶的必填項,如果沒填,就提示該項不能為空。步驟:頁面中插入RequiredFieldValidator控件與Button控件設(shè)置控件的相關(guān)屬性關(guān)鍵代碼:<h3>驗(yàn)證是否輸入必填信息</h3><formid="form1"runat="server"><div>用戶名:<asp:TextBoxID="TextBox1"runat="server"></asp:TextBox><br/><asp:RequiredFieldValidatorID="RequiredFieldValidator1"ControlToValidate="TextBox1"runat="server"ErrorMessage="RequiredFieldValidator">用戶名不能為空?</asp:RequiredFieldValidator><asp:ButtonID="Button1"runat="server"Text="檢查頁面中D的必填項"/></div></form>2、建立一個項目,要求用RangeValidator控件驗(yàn)證用戶輸入的成績是否在0~100。步驟:頁面中插入RangeValidator控件Button控件與Label控件設(shè)置控件的相關(guān)屬性,為控件添加方法聲明相應(yīng)的方法,實(shí)現(xiàn)對應(yīng)的效果關(guān)鍵代碼:<scriptlanguage="C#"runat="server">voidbutton1_click(objecto,EventArgse){RangeValidator1.Validate();if(RangeValidator1.IsValid){Label1.Text="輸入值有效";}else{Label1.Text="輸入值無效";}}</script><formid="form1"runat="server"><asp:TextBoxID="TextBox1"runat="server"></asp:TextBox><asp:RangeValidatorID="RangeValidator1"ControlToValidate="TextBox1"Type="Integer"MinimumValue="1"MaximumValue="100"runa

溫馨提示

  • 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)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論