countrymeister
asked on
How to attach a src to a iframe
I have a iFrame control on an ASP.NET aspx page.
I need to add a src value to the control. Currently it is blank
<iframe id="printFrame" runat="server" style="width:0px;height:0p x" src="" ></iframe>
The src is a pdf file that is created dynamically with the Session.SessionId appended.
Example if the Session.SessionID is "zjr5j5mw1ti1ym45o2ilkc45" , then the file will be stored on the server as
zjr5j5mw1ti1ym45o2ilkc45.p df in some location under the application.
Example ./PDFFiles/zjr5j5mw1ti1ym4 5o2ilkc45. pdf
Can I do something like this and point the src to some location of the file
<iframe id="printFrame" runat="server" style="width:0px;height:0p x" src='<%#Concat(./PDFFiles/ Session.Se ssionID.Va lue,.pdf %>) ></iframe>
I need to add a src value to the control. Currently it is blank
<iframe id="printFrame" runat="server" style="width:0px;height:0p
The src is a pdf file that is created dynamically with the Session.SessionId appended.
Example if the Session.SessionID is "zjr5j5mw1ti1ym45o2ilkc45"
zjr5j5mw1ti1ym45o2ilkc45.p
Example ./PDFFiles/zjr5j5mw1ti1ym4
Can I do something like this and point the src to some location of the file
<iframe id="printFrame" runat="server" style="width:0px;height:0p
ASKER
Well, maybe my question is very generic, but I have tried my best to explain what needs to be done.
I very well know how to do the simple stuff as adding a basic src, what I need is to attach a Session.SessionID. alonwith the path name of he location of the src.
I am not a javscript/html expert and need to know if the following will work
Can I do something like this and point the src to some location of the file
<iframe id="printFrame" runat="server" style="width:0px;height:0p x" src='<%#Concat(./PDFFiles/ Session.Se ssionID.Va lue,.pdf %>) ></iframe>
I very well know how to do the simple stuff as adding a basic src, what I need is to attach a Session.SessionID. alonwith the path name of he location of the src.
I am not a javscript/html expert and need to know if the following will work
Can I do something like this and point the src to some location of the file
<iframe id="printFrame" runat="server" style="width:0px;height:0p
yes. But you will need to "quote" your path. Which scripting language is that? Syntax may vary.
<%#Concat("./PDFFiles/Sess ion.Sessio nID.Value" ,".pdf" %>)
in PHP it would be somewhat different.
<?php echo $_SERVER["DOCUMENT_ROOT"]. "/PDFFiles /Session.S essionID.V alue".".pd f"; ?>
D
<%#Concat("./PDFFiles/Sess
in PHP it would be somewhat different.
<?php echo $_SERVER["DOCUMENT_ROOT"].
D
ASKER
I need the solution in ASP.NET
don't know what exactly your Concat() returns as result, but you src= attribute most likely need to look like:
src='<%#Concat(./PDFFiles/ Session.Se ssionID.Va lue,.pdf) %>'
or
src="<%#Concat(./PDFFiles/ Session.Se ssionID.Va lue,.pdf) %>"
src='<%#Concat(./PDFFiles/
or
src="<%#Concat(./PDFFiles/
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Dennis,
It gives me an error stating - Too many characters in character literal, when I do a build.
So I did the following
<iframe id="printFrame" runat="server" style="width:0px;height:0p x" src="~/PDFFiles/<%#Respons e.Write(Se ssion.Sess ionID.Valu e) %>.pdf"> ></iframe>
I believe with ASP.NET 2.0 you can add a runat="server" for an HTML tag.
Thanks for your help
It gives me an error stating - Too many characters in character literal, when I do a build.
So I did the following
<iframe id="printFrame" runat="server" style="width:0px;height:0p
I believe with ASP.NET 2.0 you can add a runat="server" for an HTML tag.
Thanks for your help
countrymeister,
I am glad you sorted out the runat and that things are working now.
D
I am glad you sorted out the runat and that things are working now.
D
e.g.
<iframe id='myframe' src='test1.html' width=100 height=100></iframe>
<button onclick='document.getEleme
D