gt系统管理员lt/asp:ListItemgt ltasp:ListItemgt高级用户lt/asp:ListItemgt ltasp:ListItem Selected quottruequotgt普通用户lt/asp:ListItemgt ltasp:ListItemgt游客lt/asp:ListItemgt lt/asp:DropDownListgt ltpgtlt/pgt 您选择的登录方式为:ltasp:Label runat quotserverquot ID quotLabel1quot Text quot普通用户quotgtlt/asp:Labelgt lt/formgtlt/bodygtlt/htmlgtex4_1.aspx.cs 的代码如下所示:public partial class ex4_1 : System.Web.UI.Page protected void Page_Loadobject sender EventArgs e protected void DisplayTypeobject sender EventArgs e Label1.Text DropDownList1.Text 2、在 ex4_2.aspx 文件中代码如下所示:lt Page LanguagequotCquot AutoEventWireupquottruequot CodeFilequotex4_2.aspx.csquotInheritsquotex4_2quot gtltDOCTYPE html PUBLIC quot-//W3C//DTD XHTML 1.0 Transitional//ENquotquothttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtdquotgtlthtml xmlnsquothttp://www.w3.org/1999/xhtmlquotgtlthead runatquotserverquotgt lttitlegt日期选择lt/titlegtlt/headgtltbodygt ltform idquotform1quot runatquotserverquotgt ltdivgt ltasp:Calendar IDquotCalendar1quot runatquotserverquotondayrenderquotCalendar1_DayRenderquotgt lt/asp:Calendargt lt/divgt lt/formgtlt/bodygtlt/htmlgtex4_2.aspx.cs 的代码如下所示:public partial class ex4_2 : System.Web.UI.Page protected void Page_Loadobject sender EventArgs e protected void Calendar1_DayRenderobject sender DayRenderEventArgs e if e.Day.IsOtherMonth ampamp e.Day.IsWeekend e.Cell.BackColor System.Drawing.Color.Yellow else if e.Day.IsOtherMonth ampamp e.Day.IsWeekend e.Cell.BackColor System.Drawing.Color.Red e.Day.IsSelectable false 3、在 ex4_3.aspx 文件中代码如下所示:ltbodygt ltform idquotform1quot runatquotserverquotgt ltdivgt 请选择您最喜欢的网站 ltpgtlt/pgt ltasp:BulletedList runat quotserverquot ID quotBulletedList1quot BulletStylequotDiscquotDisplayModequotLinkButtonquot OnClickquotItemsBulletedList_Clickquotgt ltasp:ListItem Value quothttp://www.baidu.comquotgt百度lt/asp:ListItemgt ltasp:ListItem Value quothttp://www.google.comquotgt谷歌lt/asp:ListItemgt ltasp:ListItem Value quothttp://www.sina.com.cnquotgt新浪lt/asp:ListItemgt lt/asp:BulletedListgt ltpgtlt/pgt 您最喜欢的网站是:ltasp:Label runat quotserverquot ID quotLabel1quotgtlt/asp:Labelgt lt/divgt lt/formgtlt/bodygt在 ex4_3.aspx.cs 文件中代码如下所示:public partial class ex4_3 : System.Web.UI.Page protected void Page_Loadobject sender EventArgs e protected void ItemsBulletedList_Clickobject sender BulletedListEventArgs e switch e.Index case 0: Label1.Text quot百度quot break case 1: Label1.Text quot谷歌quot break case 2: Label1.Text quot新浪quot break Chap05 参考答案一、填空题1、客户端数据验证 服务器端数据验证2、RequiredFieldValidator3、CompareValidator4、RegularExpressionValidator5、.ascx二、1.D 2. D 3.ABCD 4、C 5、AB三、上机操作题1、ex5_1.aspx 的源代码如下:lt Page LanguagequotCquot AutoEventWireupquottruequot CodeFilequotex5_1.aspx.csquotInheritsquotex5_1quot gtltDOCTYPE html PUBLIC quot-//W3C//DTD XHTML 1.0 Transitional//ENquotquothttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtdquotgtlthtml xmlnsquothttp://www.w3.org/1999/xhtmlquot gtlthead runatquotserverquotgt lttitlegt数字输入lt/titlegtlt/headgtltbodygt ltform idquotform1quot runatquotserverquotgt ltdivgt 请输入:ltasp:TextBox IDquotTextBox1quot runatquotserverquotgtlt/asp:TextBoxgt ltasp:CompareValidator IDquotCompareValidator1quot runatquotserverquotControlToValidatequotTextBox1quot ErrorMessagequot只能输入数字类型。
quotTypequotDoublequotgtlt/asp:CompareValidatorgtlt/divgt lt/formgtlt/bodygtlt/htmlgt 2、ex5_2.aspx 的源代码如下:lt Page LanguagequotCquot AutoEventWireupquottruequot CodeFilequotex5_2.aspx.csquotInheritsquotex5_2quot gtltDOCTYPE html PUBLIC quot-//W3C//DTD XHTML 1.0 Transitional//ENquotquothttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtdquotgtlthtml xmlnsquothttp://www.w3.org/1999/xhtmlquot gtlthead runatquotserverquotgt lttitlegt判断日期lt/titlegtlt/headgtltbodygt ltform idquotform1quot runatquotserverquotgt ltdivgt 请输入日期:ltbr /gt ltasp:TextBox IDquotTextBox1quot runatquotserverquotgtlt/asp:TextBoxgt ltasp:RangeValidator IDquotRangeValidator1quot runatquotserverquotControlToValidatequotTextBox1quot ErrorMessagequot所输入日期必须在日期在 2007 年 3 月之后quotMaximumValuequot9999-09quot MinimumValuequot2007-03quotgtlt/asp:RangeValidatorgtlt/divgt lt/formgtlt/bodygtlt/htmlgt 3、身份验证用户控件的源代码如下:lt Control LanguagequotCquot AutoEventWireupquottruequot CodeFilequotIDValidate.ascx.csquotInheritsquotIDValidatequot gtltasp:TextBox IDquotTextBox1quot runatquotserverquotgtlt/asp:TextBoxgtltasp:RegularExpressionValidator IDquotRegularExpressionValidator1quot runatquotserverquotControlToValidatequotTextBox1quot ErrorMessagequot您输入的身份证号码有误,请重新输入!quotValidationExpressionquotd17dXd15quotgtlt/asp:RegularExpressionValidatorgtex5_3.aspx 的源代码如下:lt Page LanguagequotCquot AutoEventWireupquottruequot CodeFilequotex5_3.aspx.csquotInheritsquotex5_3quot gtlt Register srcquotIDValidate.ascxquot tagnamequotIDValidatequot tagprefixquotuc1quot gtltDOCTYPE html PUBLIC quot-//W3C//DTD XHTML 1.0 Transitional//ENquotquothttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtdquotgtlthtml xmlnsquothttp://www.w3.org/1999/xhtmlquotgtlthead runatquotserverquotgt lttitlegt输入身份证号码lt/titlegtlt/headgtltbodygt ltform idquotform1quot runatquotserverquotgt ltdivgt 请输入您的身份证号码:ltuc1:IDValidate IDquotIDValidate1quot runatquotserverquot /gt ltbr /gt ltbr /gtampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbsp ltasp:Button IDquotButton1quot runatquotserverquot Textquot提交quot /gt lt/divgt lt/formgtlt/bodygtlt/htmlgtChap06 参考答案一、1.Connection Command DataSetCommand DataSet DataReader 2.数据处理 Connection Command DataReader DataAdapter 3.User ID(uid)
上一篇:
【精品】ASP新闻发布系统论文
下一篇:
十年前与十年后,我们得到了什么?又失去了什么?