如何使用ASP产生象安装向导的主页

如何使用ASP产生象安装向导的主页

面临的主要问题何在:

1。界面和一个Windows Wizard完全一样,有Next和Back按钮
2。用户可以使用Back按钮回到以前的任何一步,并且能够改变以前任何一步中已经选择的内容
3。Form必须记住所有填入的内容
4。不能够使用数据库
5。不能够使用Sessions,防止如果Sessiosn失效后用户的所有输入丢失,不幸的是,也不能够使用cookie
因为很多拥护经常关掉浏览器的Cookie选项。
6。可移植性要好,因为它要适应安装步数不同时的情况

解决方案:
1。使用hidden变量传递参数
2。使用POST方式,不使用GET方式,因为这种方式受长度限制
3。每一个页面都必须有一个用来读取提交值的函数
4。每一个页面(除了第一个页面外)都必须要有一个hidden form 来向前一页传递参数

如果在你的页面中使用了Checkboxes或则使用了radio buttons,请使用以下代码读数值:

1 For Each Item in Request.Form   
2If Request.Form(Item).Count Then   
3For intLoop = 1 to Request.Form(Item).Count   
4Response.Write "Item = " & Item & " Index = " & intLoop & "

<br/>

1"   
2Next   
3Else   
4Response.Write "Item = " & Item & "

<br/>

1"   
2End If   
3Next   

在设计是,对checkboxes和radio采用了特殊的处理方法:
1。只有最新的数值才被考虑使用这两种方式保存
2。用户可以使用Back来改变前面输入的数值,但必须要使用Next提交后才能够生效
3。页面必须要能够应付一个页面有多个controls的情况

具体实现方法:
第N个页面应该有:
1。第一个form:它的ACTION= page(N+1).asp和它底部必须有Next按钮
2。第二个form:它的ACTION= page(N-1).asp和Back按钮
3。变量命名规则:举例:N_

1<page no=""> 后缀是控件类型. <input name="RADIO_P2" type="RADIO"/>   
2是表示第二页的一个name是radio的东西   
34。一个用来读取提交的函数   
4  
5页面根据一个循环来判断当前的控件是属于哪一页的。   
6代码如下:   

@LANGUAGE="VBSCRIPT

1<html>
2<head>
3</head>
4<body>
5<!-- NEXT按钮模块编程开始 -->
6<form action="page03.asp" method="POST">
7<!------------------------------------------------------------->
8<!--读入函数开始 -->
9<!------------------------------------------------------------->   

pageno = "_P2"
For Each Item in Request.Form
WhichPage = InStr(1,CStr(Item), pageno,1)
If ((Request.Form(Item).Count) AND (WhichPage = 0)) Then
strCount = Request.Form(Item).Count
strItem = Request.Form(Item)(strCount)
Response.Write "<input "="" """="" &="" hidden""="" item="" name="" stritem="" type="" value=""/>" &amp;VbCrLf
ElseIf (NOT(Request.Form(Item).Count) AND (WhichPage = 0)) Then
Response.Write "<input "="" """="" &="" hidden""="" item="" name="" stritem="" type="" value=""/>" &amp;VbCrLf
End If
Next

1<!------------------------------------------------------------>   
2&lt;1-- 读入函数结束 --&gt;   
3<!------------------------------------------------------------>
4<!-- #include file = "Check_UnCheck.txt" -->   

Function Check_UnCheck(ctrlName, ctrlValue)
Dim ctrlName_in
Dim ctrlValue_in
Dim ctrlValue_actual
Dim outStr

ctrlValue_in =""
ctrlName_in = ""
ctrlValue_actual = ""
outStr = ""
ctrlName_in = ctrlName_in &amp; ctrlName
ctrlValue_in = ctrlValue_in &amp; ctrlValue

If Request.Form(ctrlName_in).Count Then
strCount = Request.Form(ctrlName_in).Count
ctrlValue_actual = Request.Form(ctrlName_in)(strCount)
If ctrlValue_actual = ctrlValue_in Then
outStr = "CHECKED"
End If
Else
ctrlValue_actual = Request.Form(ctrlName_in)
If ctrlValue_actual = ctrlValue_in Then
outStr = "CHECKED"
End If
End If
Check_UnCheck = outStr
End Function

1  
2<!-- Back按钮模块开始 -->   
3  

strItem1 = ""
strItem1a = ""
For Each Item1 in Request.Form
If Request.Form(Item1).Count Then
strCount1 = Request.Form(Item1).Count
strItem1 = Request.Form(Item1)(strCount1)
Response.Write "<input "="" """="" &="" hidden""="" item1="" name="" stritem1="" type="" value=""/>" &amp;VbCrLf
strCount1 = ""
strItem1 = ""
Else
strItem1a = Request.Form(Item1)
Response.Write "<input "="" """="" &="" hidden""="" item1="" name="" stritem1a="" type="" value=""/>" &amp;VbCrLf
End If
Next

strItem1 = ""
strItem1a = ""

Published At
Categories with Web编程
Tagged with
comments powered by Disqus