p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

proasp_codeclinic thread: frames, target frame problem,,,,


Message #1 by "Taher Moiyed" <taherm@f...> on Fri, 8 Jun 2001 10:14:23
If I understand your code correctly (why does DreamWeaver make suck a 
mess.....) then here is what happens:

    If (MM_editRedirectUrl <> "") Then
      Response.Redirect(MM_editRedirectUrl)
    End If
  
At then end of the processing, the page is redirected to MM_editRedirectUrl
(which should contain main.asp)

Now, this is called from the bottom frame, so the new page will also load 
in the same frame. You can use some JavaScript to overcome this.

Replace the previous code with this:

With Response
    .Write("<script language=""JavaScript"">" & vbCRLF)
    .Write("top.location.href=""" & MM_editRedirectUrl & """" & vbCRLF)
    .Write("</script>")
    .End
End With

This will write some JavaScript to the browser that forces a client-side 
redirect to main.asp which will load in the top frame (top.location)

Hope this helps,

Imar




> i have 2 frames on my asp page namely top.asp and bottom.asp and the 
page 
> is called main.asp
> in otherwords in main.asp there are 2 frames top and bottom.
> 
> there is a link in in the top frame called add new client. the moment 
the 
> user clicks on teh link an insert user form appears in teh bottom frame. 
> user fills in the information and then clicks the add button.
> 
> it works fine until here.
> 
> but i want the user to be redirected to main.asp. i am using ultradev 
and 
> in there i can specify which page i wnat to go after the user has added 
> the data. i have specified main.asp 
> what actually happens is that main.asp opens in the bottom frame.
> basically i am looking for a target parent or blank frame code in asp
> here is my code
> 
> <%@LANGUAGE="VBSCRIPT"%>
> <!--#include file="../Connections/clientdb.asp" -->
> <%
> ' *** Edit Operations: declare variables
> 
> MM_editAction = CStr(Request("URL"))
> If (Request.QueryString <> "") Then
>   MM_editAction = MM_editAction & "?" & Request.QueryString
> End If
> 
> ' boolean to abort record edit
> MM_abortEdit = false
> 
> ' query string to execute
> MM_editQuery = ""
> %>
> <%
> ' *** Insert Record: set variables
> 
> If (CStr(Request("MM_insert")) <> "") Then
> 
>   MM_editConnection = MM_clientdb_STRING
>   MM_editTable = "ClientDetails"
>   MM_editRedirectUrl = "main.asp " 
>   MM_fieldsStr  
> 
= "clientaccountnumber|value|companyname|value|add1|value|add2|value|add3|v
> 
alue|add4|value|postcode|value|country|value|telnumber|value|faxnumber|valu
> 
e|primarywebaddress|value|mainemailaddress|value|accmanager|value|accmanage
> remail|value"
>   MM_columnsStr 
> 
= "ClientAccountNumber|',none,''|CompanyName|',none,''|Add1|',none,''|Add2|
> ',none,''|Add3|',none,''|Add4|',none,''|Postcode|',none,''|Country|',none
,'
> '|TelNumber|',none,''|FaxNumber|',none,''|PrimaryWebAddress|',none,''|Mai
nE
> maiAddress|',none,''|AccManager|',none,''|AccManagerEmail|',none,''"
> 
>   ' create the MM_fields and MM_columns arrays
>   MM_fields = Split(MM_fieldsStr, "|")
>   MM_columns = Split(MM_columnsStr, "|")
>   
>   ' set the form values
>   For i = LBound(MM_fields) To UBound(MM_fields) Step 2
>     MM_fields(i+1) = CStr(Request.Form(MM_fields(i)))
>   Next
> 
>   ' append the query string to the redirect URL
>   If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
>     If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And 
> Request.QueryString <> "") Then
>       MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
>     Else
>       MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
>     End If
>   End If
> 
> End If
> %>
> <%
> ' *** Insert Record: construct a sql insert statement and execute it
> 
> If (CStr(Request("MM_insert")) <> "") Then
> 
>   ' create the sql insert statement
>   MM_tableValues = ""
>   MM_dbValues = ""
>   For i = LBound(MM_fields) To UBound(MM_fields) Step 2
>     FormVal = MM_fields(i+1)
>     MM_typeArray = Split(MM_columns(i+1),",")
>     Delim = MM_typeArray(0)
>     If (Delim = "none") Then Delim = ""
>     AltVal = MM_typeArray(1)
>     If (AltVal = "none") Then AltVal = ""
>     EmptyVal = MM_typeArray(2)
>     If (EmptyVal = "none") Then EmptyVal = ""
>     If (FormVal = "") Then
>       FormVal = EmptyVal
>     Else
>       If (AltVal <> "") Then
>         FormVal = AltVal
>       ElseIf (Delim = "'") Then  ' escape quotes
>         FormVal = "'" & Replace(FormVal,"'","''") & "'"
>       Else
>         FormVal = Delim + FormVal + Delim
>       End If
>     End If
>     If (i <> LBound(MM_fields)) Then
>       MM_tableValues = MM_tableValues & ","
>       MM_dbValues = MM_dbValues & ","
>     End if
>     MM_tableValues = MM_tableValues & MM_columns(i)
>     MM_dbValues = MM_dbValues & FormVal
>   Next
>   MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues 
> & ") values (" & MM_dbValues & ")"
> 
>   If (Not MM_abortEdit) Then
>     ' execute the insert
>     Set MM_editCmd = Server.CreateObject("ADODB.Command")
>     MM_editCmd.ActiveConnection = MM_editConnection
>     MM_editCmd.CommandText = MM_editQuery
>     MM_editCmd.Execute
>     MM_editCmd.ActiveConnection.Close
> 
>     If (MM_editRedirectUrl <> "") Then
>       Response.Redirect(MM_editRedirectUrl)
>     End If
>   End If
> 
> End If
> %>
> <%
> set Recordset1 = Server.CreateObject("ADODB.Recordset")
> Recordset1.ActiveConnection = MM_clientdb_STRING
> Recordset1.Source = "SELECT * FROM ClientDetails"
> Recordset1.CursorType = 0
> Recordset1.CursorLocation = 2
> Recordset1.LockType = 3
> Recordset1.Open()
> Recordset1_numRows = 0
> %>
> <html>
> <head>
> <title>Untitled Document</title>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
> </head>
> <body bgcolor="#FFFFFF" text="#000000">
> <p>Enter New Client Details</p>
> <form name="form1" method="POST" action="<%=MM_editAction%>">
>   <p>  </p>
>   <table width="878" border="0" cellspacing="0" cellpadding="0">
>     <tr> 
>       <td width="163">Client Account Number:</td>
>       <td width="130"> 
>         <input type="text" name="clientaccountnumber">
>       </td>
>       <td width="107">Company Name: </td>
>       <td width="133"> 
>         <input type="text" name="companyname">
>       </td>
>     </tr>
>     
> </table>
>   <p> 
>     <input type="submit" name="Submit" value="Add New">
>   </p>
>   <input type="hidden" name="MM_insert" value="true">
> </form>
> <p>  </p>
> </body>
> </html>
> <%
> Recordset1.Close()
> %>
> 
> thanks for your help in advance.

  Return to Index