Amutha Amutha - 7 months ago 27
Javascript Question

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

In my asp page i have a checkbox and table(contains 5 tds).while page loading checkbox should be unchecked and only one "td" should appear in the table.After Clicking checkbox only second Td will appear.After that any validation error occurs while clicking on submit button the page should be retained only.But it's not working

Answer

I would suggest using Sessions. Also 1 page to get input , 1 page to process input.

View Bit(index.asp)

<input name="username" type="text" value="<%=session("username")%>
 <%
   if Session("error")=true then  
    response.write("Username cannot be blank") end if
 %>

Process Bit (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

 %>

Since the input has been set to session , all of it will remain even when redirected back from the processing page . Just dont forget to clear the appropriate session data when its not needed anymore.

Comments