一个简单的在线考试小程序
终极管理员 知识笔记 105阅读
刚刚从ASP .网那里得知。前两天编了一个简单的在线考试小程序,很粗糙。希望大家给点建议。我还是把代码更正如下:1脚本语言=' VB ' runat=' server ' 2 subpage _ load()subpage _ load(senderas object,easeventargs) 3响应。饼干("我的饼干")。值('用户名)=(0,0,0,1)'名称。文本4响应。饼干(“我的饼干”).值('用户号')=数字。文本5响应。饼干(“我的饼干”).值('元')=元。选择编辑项目。文本6响应。饼干(“我的饼干”).值('上次访问')=日期时间。现在。tolongtimestring()7响应。饼干(‘我的饼干
style="color: rgba(0, 0, 0, 1)">").expires=datetime.now.adddays(7)8end sub
9sub button_click(sender as object,e as eventargs)
10dim mycookie as HttpCookie=request.cookies("mycookie")
11message2.text="<h2>您登陆的时间为:" & mycookie.values("lastvisited") & "</h2>"
12if number.text mod 2=0 then
13juan2.visible="true"
14juan1.visible="false"
15message1.text="<h2>您的姓名为:" & name.text & "<br>" & "您的学号为:" & number.text & "<br>" & "您是" & yuan.selecteditem.text & "的学生,您的学号为偶数,做B卷</h2>"
16else
17juan1.visible="true"
18juan2.visible="false"
19message1.text="<h2>您的姓名为:" & name.text & "<br>" & "您的学号为:" & number.text & "<br>" & "您是" & yuan.selecteditem.text & "的学生,您的学号为奇数,做A卷</h2>"
20end if
21end sub
22sub button2_click(sender as object,e as eventargs)
23dim msg as string=""
24if radiobuttonlist.items(2).selected
25msg=msg & "<br>" & "<h3>您做对了,恭喜您得100分</h3>"
26else
27msg=msg & "<br>" & "<h3>您做错了,继续努力把</h3>"
28end if
29if page.isvalid then
30message.text=msg
31end if
32end sub
33sub button3_click(sender as object,e as eventargs)
34dim msg as string=""
35if today.items(2).selected or today.items(3).selected then
36msg=msg & "<br>" & "<h3>您做错了,继续努力把</h3>"
37else
38msg=msg & "<br>" & "<h3>您做对了,恭喜您得100分</h3>"
39end if
40if page.isvalid then
41message0.text=msg
42end if
43end sub
44sub button1_click(sender as object,e as eventargs)
45page.response.redirect("\index.aspx")
46end sub
47</script>
48<head>
49<style type="text/css">
50<!--
51body {background-color: #98AB6F }
52h1 {font: 16pt/18pt "Arial"; font-weight: bold; color: maroon}
53h2 {font: 13pt/15pt "Arial"}
54h3 {font: 14pt/16pt "Arial"; font-weight: bold; color:crimson}
55-->
56</style>
57</head>
58<body>
59 <form runat="server">
60<asp:panel runat="server" id="ziliao">
61<fieldset>
62<legend><h1>个人资料<h1></legend>
63姓名:
64<asp:textbox runat="server" id="name" columns="7"/>
65<asp:requiredfieldvalidator runat="server" controltovalidate="name" errormessage="请输入姓名"/>
66<br>
67学号:
68<asp:textbox runat="server" id="number" columns="7"/>
69<asp:regularexpressionvalidator runat="server" enableclientscript="false" controltovalidate="number" validationexpression="[0-9]{7}" errormessage="学号输入有误"/>
70<asp:requiredfieldvalidator runat="server" controltovalidate="number" errormessage="请输入学号"/>
71<br>
72学院:
73<asp:dropdownlist runat="server" id="yuan">
74<asp:listitem>海洋学院</asp:listitem>
75<asp:listitem>信息学院</asp:listitem>
76<asp:listitem>人文学院</asp:listitem>
77<asp:listitem>食品学院</asp:listitem>
78</asp:dropdownlist>
79</fieldset>
80<asp:button runat="server" text="提交资料" id="button" onclick="button_click"/>
81<asp:button runat="server" text="重新填写" id="button1" onclick="button1_click"/>
82</asp:panel>
83 <asp:label runat="server" id="message1"/>
84<span id=applelew>
85
86<script>
87function show2(){
88if (!document.all)
89return
90var Digital=new Date()
91var hours=Digital.getHours()
92var minutes=Digital.getMinutes()
93var seconds=Digital.getSeconds()
94if (minutes<=9)
95minutes="0"+minutes
96if (seconds<=9)
97seconds="0"+seconds
98var ctime=hours+":"+minutes+":"+seconds+" "
99applelew.innerHTML="<h2 style='color:blue;'>现在的时间是:"+ctime+"</h2>"
100setTimeout("show2()",1000)
101}
102window.onload=show2
103</script>
104</span>
105<asp:label runat="server" id="message2"/>
106<asp:panel runat="server" id="juan1" visible="false">
107<fieldset>
108<legend><h1>A卷题目:</h1></legend>
109明末引清兵进关的是:<br>
110<asp:radiobuttonlist runat="server" id="radiobuttonlist" repeatdirection="horizontal">
111<asp:listitem>吴一桂</asp:listitem>
112<asp:listitem>吴二桂</asp:listitem>
113<asp:listitem>吴三桂</asp:listitem>
114<asp:listitem>吴四桂</asp:listitem>
115</asp:radiobuttonlist>
116<br>
117<asp:button runat="server" text="提交" id="button2" onclick="button2_click"/>
118<br>
119<asp:label runat="server" id="message"/>
120</fieldset>
121</asp:panel>
122<asp:panel runat="server" id="juan2" visible="false">
123<fieldset>
124<legend><h1>B卷题目:</h1></legend>
125中国的政治和经济中心分别是:<br>
126<asp:checkboxlist runat="server" id="today" repeatdirection="horizontal">
127<asp:listitem>北京</asp:listitem>
128<asp:listitem>上海</asp:listitem>
129<asp:listitem>西藏</asp:listitem>
130<asp:listitem>山东</asp:listitem>
131</asp:checkboxlist>
132<br>
133<asp:button runat="server" text="提交" id="button3" onclick="button3_click"/>
134<br>
135<asp:label runat="server" id="message0"/>
136</fieldset>
137</asp:panel>
138</form>
139</body>
140</html>

标签: