一、选择题
- 在窗口打印” NEWER”
- 在窗口打印” <H1> NEWER </H1>”
- 在窗口打印” H1 NEWER H1”
- 出现错误信息,说明嵌入的串中包含非法字符
- <httpRuntime>
- <pages>
- <appSetting>
- <sessionState>
private void InitializeComponent()
{
this.btnAdd.Click += new System.EventHandler(this.Button1_Click);
this.btnSubtract.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
private void Page_Load(object sender, System.EventArgs e)
{
btnAdd.CommandName=”Add”;
btnSubtract.Command=”Subtract”;
}
private void Button1_Click(object sender, System.EventArgs e)
{
int op1 = Convert.ToInt16(TextBox1.Text);
int op2 = Convert.ToInt16(TextBox2.Text);
int result = 0;
(1)
switch(name) {
case “Add” :
result = op1 + op2;
break;
case “Subtract” :
result = op1 – op2;
break;
}
Label1.Text = result.ToString();
}
- string name= sender. CommandName;
- string name=e. CommandName;
- string name=((Button)sender).CommandName;
- string name= btnAdd. CommandName;
public class WebForm1: System.Web.UI.Page{
protected System.Web.UI.WebControls.RadioButton RadioButton1;
protected System.Web.UI.WebControls.RadioButton RadioButton2;
protected System.Web.UI.WebControls.RadioButton RadioButton3;
protected System.Web.UI.WebControls.Image Image1;
protected HtmlForm Form1;
private void Button1_Click(object sender, System.EventArgs e)
{
(1)
{
if(control is RadioButton)
{
RadioButton rb=control as RadioButton;
if(rb.Checked)
{
ListBox1.Items.Add(rb.Text);
break;
}
}
}
}
}
- foreach(object control in this.Controls)
- foreach(object control in Page.Controls)
- foreach(object control in Form1.Controls)
- foreach(object control in WebForm1.Controls)
A.Hashtable ht=new Hashtable();
ht.Add(“java”,”s1课程”);
ht.Add(“jsp”,”s2课程”);
ht.Add(“j2ee”,”y2课程”);
RadioButtonList1.DataSource=ht;
RadioButtonList1.DisplayMember=”key”;
RadioButtonList1.ValueMember=”value”;
RadioButtonList1.DataBind();
B. ListItem item1=new ListItem(“java”,”s1课程”);
ListItem item2=new ListItem(“jsp”,”s2课程”);
ListItem item3=new ListItem(“j2ee”,”y2课程”);
RadioButtonList1.Items.Add(item1);
RadioButtonList1.Items.Add(item2);
RadioButtonList1.Items.Add(item3);
C. Hashtable ht=new Hashtable();
ht.Add(“java”,”s1课程”);
ht.Add(“jsp”,”s2课程”);
ht.Add(“j2ee”,”y2课程”);
RadioButtonList1.DataSource=ht;
RadioButtonList1.DataBind();
D.RadioButtonList1.Items.Add(“java”,”s1课程”);
RadioButtonList1.Items.Add(“jsp”,”s2课程”);
RadioButtonList1.Items.Add(“j2ee”,”y2课程”);
string[] files=Directory.GetFiles(Server.MapPath(“image/”));
foreach(string file in files)
RadioButtonList1.Items.Add(name);
A. string[] names=file.Split(‘’);
string name=names[names.Length-1];
B. string name=Path.GetFileName(file);
C. string[] names=file.Split(“”);
string name=names[names.Length-1];
D. FileInfo info=new FileInfo(file);
string name=info.FileName;
- RadioButtonList
- CheckBoxList
- DropDownList
- ListBox
- SqlServer:Provider=SQLOLEDB;server=.;database=pubs;uid=sa;pwd=123
- Oracle:Provider=MSDAORA.1;Data Source=newer;User ID=scott; PassWord=tiger
- Access:Provider=Microsoft.Jet.OLEDB.4.0;Data Source=1.mdb
- Excel:”Provider=Microsoft.Jet.OLEDB.4.0;Data Source=” + Server.MapPath(“1.xls”)
- Label,int count,<%# count%>
- TextBox,void Count(){},<%# Count()%>
- Repeater,ArrayList list, <%# Container.DataItem%>
- Repeater,Hashtable list, <%# Container.DataItem%>
- int i=0;object o1=i;object o2=(object)i;
- int i=0;object o=i;int i1=o;int i2=(object)o;int i3=(int)o;
- int i=0; long l1=i;long l2=( long)i;
- int i=0; object o1=i;long l1=( int)o1;long l2=(long)o1;
class Father{
public void F() { Console.WriteLine(“A.F”); }
public virtual void G() { Console.WriteLine(“A.G”); }
}
class Son: Father{
new public void F() { Console.WriteLine(“B.F”); }
public override void G() { Console.WriteLine(“B.G”); }
}
class override_new
{
static void Main() {
Son b = new Son();
Father a = b;
a.F();
b.F();
a.G();
b.G();
}
}
- A.F B.F A.G B.G
- A.F B.F B.G B.G
- A.F A.F B.G B.G
- B.F B.F B.G B.G
二、问答题
页面对象模型
1.<%@Page%>中的Codebehind、AutoEventWireup、Inherits有何作用?
2.怎样计算页面执行的时间?
Web服务
1. 使用Web服务实现文件上传、下载的功能。
2. 使用无刷新技术调用Web服务每隔1秒钟显示某个字段的随机行的记录值。
缓存机制
1. 缓存的几种不同的实现方法。
自定义控件
1. 使用自定义控件创建一个只能输入数字、禁止复制,禁止剪切,禁止粘贴的文本框,添加到工具箱后显示一个指定的图标
ADO.NET
1. 论述ASP.NET中的四种事务机制的异同。
2. 比较三种使用ADO.NET对象读取数据的方法。
3. 描述SqlCommandBuilder的两种用法。
客户端脚本
1. 滚动的图片:在页面中以向上滚动的方式显示某个文件夹中的图片。鼠标移进时停止滚动,鼠标移出时恢复滚动。鼠标点击时弹出窗体显示图片,窗体只有标题栏,大小与图片一致。用户点击图片名称后出现文件下载界面。
2. 倒数计时:点击[计时开始]按钮,按钮的文本变为[还剩10秒关闭本窗体],每隔一秒数字减1,到0时关闭本窗体。
3. 点击服务器端按钮,将服务器端文本框中的文本在对话框中显示出来,对话框有一个[确认]按钮,一个[取消]按钮。用户点击[确定]按钮,则将服务器端复选框选中,用户点击[取消]按钮,则不选中服务器端复选框。
列表控件
1. 实现列表控件的如下功能:在两个ListBox中间有四个排成一列的按钮。点击第一个按钮,将左边ListBox的数据全部剪切到右边的ListBox中,第四个按钮的功能与之相反。点击第二个按钮,将左边ListBox被选中的数据全部剪切到右边的ListBox中,第三个按钮的功能与之相反。
2. 使用一个CheckBoxList从Color中取出所有的颜色,用户选中多项后显示在RadioButtonList中,用户选中一项将RadioButtonList的背景色改为选中的项对应的颜色。
状态管理
1.使用cookie、Session、Hashtable制作注册登录注销页面:
注册页面:点击[注册]按钮,如果用户名在Hashtable中不存在,则将用户名和密码存入Hashtable;否则提示“该用户名已经被使用!”。点击[登录页面]按钮,进入登录页面。
登录页面:点击[登录]按钮,如果用户名和密码能够在Hashtable中找到匹配的键/值对,则进入注销页面;否则提示“用户名或密码错误!”。如果用户选中[两周内不用登录]复选框,点击[登录]按钮时,将用户名和密码使用MD5CryptoServiceProvider对象进行加密后写入到响应用户的cookie中。在用户进入页面时,如果从用户的请求中得到的cookie中的用户名和密码在Hashtable中找到匹配的键/值对,则自动进入注销页面。
注销页面:如果进入页面的用户的Session不在Hashtable中,则提示“请注册后登录”,然后进入注册页面,否则在注销页面中显示登录用户的名称,所有用户的列表。点击[注销]按钮,将登录用户的Session从Hashtable中移除,并进入注册页面。
用户控件
一、制作一个Web用户控件,用来提供用户登录时的输入。
1.需要的控件有两个标签,一个单行文本框,一个密码文本框。
2.提供的属性有MaxTimes:该属性可读可写,获取或者设置允许登录失败的次数,超过该次数,页面关闭。
3.提供的方法有Login:调用该方法将连接到数据库检索用户输入(假定用户名为数据库Northiwind中表Empoyees的FirstName,密码为LastName),并根据检索结果触发事件来返回相应的信息(1.登录成功、2.登录失败,用户名不存在、3.登录失败,密码不正确、4.登录失败,超过允许登录次数、5.登录失败,数据库连接或者其他错误)。
4.提供的事件有AfterLogin:该事件在用户登录后触发,返回用户登录检查后的信息。
二、制作一个Web页面,用来提供用户登录时的确定。
1.需要的控件有两个按钮,一个标签。
2.需要的方法有:Login1_AfterLogin,显示用户登录检查后的信息,并判断如果用户的登录次数超过允许登录次数,则关闭页面。
3.点击登录按钮时,设置用户控件的属性MaxTimes,调用用户控件的方法Login。
4.点击退出按钮时,询问用户是否确定退出。



