PDA

View Full Version : Response.write into an iframe?


ScottInTexas
12-18-2002, 03:06 PM
In my ASP I am creating table. The table is written to an iframe on the calling web page. The problem is that I want the header row to stay in place in the recieving iframe and the rest of the table to scroll. My answer was to write the column headers to an iframe with no scrolling and the table to an iframe with scrolling and both these iframes written to the target.

I can't figure out how to build the big variable that will ultimately be the response.write bigBlock.


<%@ Language=VBScript %>
<% Option Explicit %>
<html>

<head>
<link rel="stylesheet" href="http://hydroenergy.intranet.dow.com/libcom/CSS/newstyle.css" type="text/css">
<title></title>
</head>

<body>
<IFRAME id='hdrFrame' marginwidth='0' scrolling='no' width='100%' height='20' frameborder='1'></IFRAME>
<IFRAME id='tblFrame' marginwidth='0' scrolling='auto' width='100%' height='100%' frameborder='1'></IFRAME>
<%

set up variable etc.

hdrDiv=hdrDiv & "<table border='1' width='100%' marginwidth='0' cellpadding='0' cellspacing='0'>"
hdrDiv=hdrDiv & "<CAPTION>" & rptTitle & "</CAPTION><tr>"
hdrDiv=hdrDiv & "<TD width='15%'>LPP#</TD>"
hdrDiv=hdrDiv & "<TD width='45%'>Comment</td>"
hdrDiv=hdrDiv & "<TD width='40%'>LPP Text</td>"
hdrDiv=hdrDiv & "</tr></table>"
bigBlock=hdrDiv & "<Script language='javascript'>hdrFrame.document.write(" & hdrDiv & ")</script>"

response.write bigBlock
%>


I left the table out of the code for brevity. It is built with a loop that loops through the rec set and fills each cell. This too is written to an iframe and the whole thing is written to the web page into a non-scrolling iframe.

Hope that is clear enough for someone to help.

ScottInTexas
12-18-2002, 05:25 PM
I almost have it. I built two variables (one for the header and one for the table). Then I created a variable holding a javascriptfunction and I wrote that to the response.


bigBlock="<Script language="
bigBlock=bigBlock & "'javascript'>"
bigBlock=bigBlock & "self.hdrFrame.document.write("%> <%= hdrDiv %> <%
bigBlock=bigBlock & ");"

bigBlock=bigBlock & "self.tblFrame.document.write("%> <%= dataTable %> <%
bigBlock=bigBlock & ");"

bigBlock=bigBlock & "<" & "/script>"
bigBlock=bigBlock & "<IFRAME id='hdrFrame' marginwidth='0' scrolling='yes' width='50'height='20%' frameborder='0'></IFRAME>"
bigBlock=bigBlock & "<IFRAME id='tblFrame' marginwidth='0' scrolling='yes' width='90%'height='80%' frameborder='1'></IFRAME>"

Response.Write(bigBlock)





Problem is everything is being written to the web page frame and not to either of these and these two frames are being created in the target.

HELP?

allida77
12-18-2002, 06:02 PM
Can this be done without an iframe having a src?

ScottInTexas
12-18-2002, 06:42 PM
I tried using src=<% =hdrDiv %> and got a 404 error. The src wants an html page. Maybe I'm doing that wrong too.

allida77
12-18-2002, 07:36 PM
What I mean by src is an actual file. I am not sure that you can work with iframes without a source(file). What you are trying to do can also be achieved with theDOM and CSS (http://www.scottandrew.com/printable/domwin_p.html) . If you still want to use iframes you are going to need to create a blank file to be the source otherwise the iframe itself has no content. I am not sure if that makes sense but I hope it leads you in the right direction.

ScottInTexas
12-18-2002, 08:11 PM
Well, I got it. This is what I ended up with.



dataTable=dataTable & "<TD class='CellSmall' align='left' valign='top' width='30'>" & objRS.Fields(Percents) & "</TD>"
dataTable=dataTable & "<TD class='CellSmall' align='left' valign='top' width='200'>" & objRS.Fields(LPPComment) & "</TD>"
dataTable=dataTable & "<TD class='CellSmall' align='left' valign='top' width='200'>" & objRS.Fields(LPPText) & "</TD>"
dataTable=dataTable & "</TR>"


finish up table

%> 'end of vbscript
<html>
<head>
<link rel="stylesheet" href="http://hydroenergy.intranet.dow.com/libcom/CSS/newstyle.css" type="text/css">
<title></title>
</head>

<body>
<IFRAME id='hdrFrame' marginwidth='0' scrolling='no' width='482' height='45' frameborder='0'></IFRAME><BR>
<IFRAME id='tblFrame' marginwidth='0' scrolling='auto' width='482' height='225' frameborder='0'></IFRAME><BR>

<Script language="javascript">
var hdtxt= "<%=hdrDiv%>";
var tbltxt="<%=dataTable%>";
document.frames("hdrFrame").document.write(hdtxt);
document.frames("tblFrame").document.write(tbltxt);
</script>

</body>



Thanks for looking. I hope someone else can use this in the future.