单击提交按钮后如何保留经典 asp 页面(同时发生验证错误)
how to retain the classic asp page after clicking on submit button( while validation error occurs)
在我的 asp 页面中,我有一个复选框和 table(包含 5 个 tds)。而页面加载复选框应该取消选中,只有一个 "td" 应该出现在 table.After 仅在第二个 Td 时单击复选框 appear.After 在单击提交按钮时发生任何验证错误,页面应保留 only.But 它不起作用
我建议使用会话。还有 1 页用于获取输入,1 页用于处理输入。
查看位(index.asp)
<input name="username" type="text" value="<%=session("username")%>
<%
if Session("error")=true then
response.write("Username cannot be blank") end if
%>
处理位 (index_process.asp)
<%
'Set error to false first everytime processed.
Session("error") = false
if Session("username) = "" then
Session("error") = true
end if
if Session("error") = true then
' If error is true , redirect back to index.asp
response.redirect("index.asp")
else
response.redirect("success_page.asp")
endif
%>
由于输入已设置为会话,因此即使从处理页面重定向回来,所有输入也会保留。只是不要忘记在不再需要时清除相应的会话数据。
在我的 asp 页面中,我有一个复选框和 table(包含 5 个 tds)。而页面加载复选框应该取消选中,只有一个 "td" 应该出现在 table.After 仅在第二个 Td 时单击复选框 appear.After 在单击提交按钮时发生任何验证错误,页面应保留 only.But 它不起作用
我建议使用会话。还有 1 页用于获取输入,1 页用于处理输入。
查看位(index.asp)
<input name="username" type="text" value="<%=session("username")%>
<%
if Session("error")=true then
response.write("Username cannot be blank") end if
%>
处理位 (index_process.asp)
<%
'Set error to false first everytime processed.
Session("error") = false
if Session("username) = "" then
Session("error") = true
end if
if Session("error") = true then
' If error is true , redirect back to index.asp
response.redirect("index.asp")
else
response.redirect("success_page.asp")
endif
%>
由于输入已设置为会话,因此即使从处理页面重定向回来,所有输入也会保留。只是不要忘记在不再需要时清除相应的会话数据。