繁体   English   中英

点击提交按钮后如何保留经典的asp页面(同时发生验证错误)

[英]how to retain the classic asp page after clicking on submit button( while validation error occurs)

在我的 asp 页面中,我有一个复选框和表格(包含 5 个 tds)。而页面加载复选框应该取消选中,表格中应该只出现一个“td”。单击复选框后,只会出现第二个 Td。之后发生任何验证错误点击提交按钮时,页面应该只保留。但它不起作用

我建议使用会话。 还有 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

 %>

由于输入已设置为会话,因此即使从处理页面重定向回来,所有内容仍将保留。 只是不要忘记在不再需要时清除相应的会话数据。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM