Skip to main content
September 2, 2011
Answered

Two redirects on same page?

  • September 2, 2011
  • 1 reply
  • 1998 views

DW CS3 - ASP

Am going through an old (but excellent) training DVD for creating Insert/Update/Delete Record forms using DW & ASP.

Two forms are created on the same page - one to Update Record and one to Delete Record.  Update works, but Delete creates an error:

     Microsoft VBScript compilation error '800a0411'

     Name redefined

     /mysitename/myfolder/admin_edit.asp, line 95

     Dim MM_editRedirectUrl

This error is apparently due to different redirect URLs for each form:

    ' append the query string to the redirect URL
    Dim MM_editRedirectUrl
    MM_editRedirectUrl = "admin_edit.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
%>

    ' append the query string to the redirect URL
    Dim MM_editRedirectUrl
    MM_editRedirectUrl = "admin_home.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
%>

I read that renaming the second Dim MM_editRedirectUrl to Dim MM_editRedirectUrl_2 will make things work correctly, and it DID!  However, does this make for an unstable environment; and if so, what's the best approach to fixing this?

This topic has been closed for replies.
Correct answer Lon_Winters

The edit page has two forms – update and delete.  The redirect URL for the update behavior stays on the edit page.  The redirect URL for the delete behavior goes to the home page.

The home page includes one insert form and a recordset.  The error happens from the home page when trying to load the edit page via the recordset and ‘go to detail page’ behavior.

Again, just going by old instruction with newer version of DW.


Ok, that makes sense. The original problem and solution stands. When the edit/detail page loads it sees the scripts and variables from both behaviors, and that the same variable name is used in both instances. So changing the variable names in one or the other behaviors will work and won't cause any instability.

1 reply

Participating Frequently
September 2, 2011

>Name redefined

means you defined the variable, and then try to define it again. That's an error in any language. Just remove the second definition entirely and it should be ok, right?

Lon_Winters
Inspiring
September 3, 2011

The problem is that DW is using the same variable name for two different operations, even though you can only use one.  There's no problem with renaming the variable in the second instance, it's just a variable name that contains the redirect URL for that operation. Just make sure you rename it wherever it appears in that block of code.  I've never heard if that making anything unstable - what makes you believe that? it is possible I guess, and if it's true I'd like to know more about it as I've often renamed these variables that DW creates.

Lon_Winters
Lon_WintersCorrect answer
Inspiring
September 3, 2011

The edit page has two forms – update and delete.  The redirect URL for the update behavior stays on the edit page.  The redirect URL for the delete behavior goes to the home page.

The home page includes one insert form and a recordset.  The error happens from the home page when trying to load the edit page via the recordset and ‘go to detail page’ behavior.

Again, just going by old instruction with newer version of DW.


Ok, that makes sense. The original problem and solution stands. When the edit/detail page loads it sees the scripts and variables from both behaviors, and that the same variable name is used in both instances. So changing the variable names in one or the other behaviors will work and won't cause any instability.