Link to home
Start Free TrialLog in
Avatar of jensjakobsen
jensjakobsenFlag for Denmark

asked on

Strictly Dreamweaver problem - redirect page after delete/insert/update

Hi

I want to redirect my users after an update/delete/insert to page where they already came from.

In short -  this is my scenario:

A: I insert data on page A. On the same page I display data created on page A as links.

B: Page B is a "detail page" (Dreamweaver lingo) based on the links from page A from where I can create more data (insert only) data as a subcategory to page A .

C: Page C is another "detail page" where I can update/delete subdata created on page B.

When I delete data on page C I want to be redirected back to page B where all the other relevant subdata to page A is shown.

Please take a look at the code provided and look for the text "createVoteType.asp" which is a redirect page I send my users to after they have updated/deleted data from page C.

I have tried a lot - like:
MM_editRedirectUrl = "createVoteType.asp?pkIntVoteID="+a variable I created dynamically from a session stored from earlier.

I hope any answers will be from experienced DW users but any help is of course very welcome.
<%
' *** Delete Record: construct a sql delete statement and execute it

If (CStr(Request("MM_delete")) = "form1" And CStr(Request("MM_recordId")) <> "") Then

  If (Not MM_abortEdit) Then
    ' execute the delete
    Set MM_editCmd = Server.CreateObject ("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_connSQL_STRING
    MM_editCmd.CommandText = "DELETE FROM dragonswim_dk.tbl71VoteAnswerType WHERE pkIntAnswerTypeID = ?"
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 5, 1, -1, Request.Form("MM_recordId")) ' adDouble
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

    ' append the query string to the redirect URL
    Dim MM_editRedirectUrl
    MM_editRedirectUrl = "createVoteType.asp"
    If (Request.QueryString <> "") Then
      If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
        MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
      Else
        MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
      End If
    End If
    Response.Redirect(MM_editRedirectUrl)
  End If

End If
%>

Open in new window

Avatar of Jason C. Levine
Jason C. Levine
Flag of United States of America image

Hi jensjakobsen,

So what exactly is not working?
Avatar of jensjakobsen

ASKER

The redirect is taking me back to "createVoteType.asp" (page B) but all variables are lost and the page is empty.
Ok.

By default, none of the DW built-in behaviors will allow you to write sessions into the redirection URL via the wizards but its fairly trivial to add the functionality if you know ASP.  However, it would make more sense to not deal with the URL if you have sessions defined and instead filter all recordsets based on the sessions.  

I assume page A links look something like this:

<a href="pageB.asp?id=XXX">

So on Page B, do something like:

Session("currentID") = Request.QueryString("id")

and then use currentID to filter the results on page B.  In order to make it work with page C's redirect, you would need to add a bit of logic to page B so that it checks to see if the query string is present.  If the query string is present, set the session variable.  If the query string is not present, do nothing, and it should retain the same value from page A and thus redisplay the data.

If you don't want to muck about the code, you will have to buy an extension to Dreamweaver than extends the functionality to get this more advanced behavior.
Hi Jason1178

On page B I already created the: Session("currentID") = Request.QueryString("id").

On page C I passed that session as a session(currentID).

On line 17 (please see attatched code) I want to create a redirect that takes them back to a correctly filtered page B.

What would the code look like?

I found it is best not to mess with MM_editRedirectUrl  and instead on line 25 remove Response.Redirect(MM_editRedirectUrl) and replace with your own code where you want to redirect to.

To keep things tidy I would also remove lines 15 - 24 that builds up the query string.

Another good option if you are using session variables, you don't need to pass it via a url on the delete page and instead use it in the your createVoteType.asp page.  Assume you have varA, varB that you are passing and your session variable is varC.  On your page that you are redirecting to you would use

assume your url is createVoteType.asp?varA=Hello&varB=Big
assume the session("varC")="World"
<%
response.write(request.querysting("varA")&"<br>")
response.write(request.querysting("varB")&"<br>")
response.write(Session("varC"))
%>
You will get
Hello
Big
World

I will try.

Good one to not use DW's own redirect page - never thought of that!

Where on the page would you put the redirect code? In the FORM?
ASKER CERTIFIED SOLUTION
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
jensjakobsen, Did this work out for you?