filling iframe with web page

P

pb

Hi all,

I have some code that automatically generates a url depending on user
selections. This url is then set as a hyperlink and the user clicks on
the link that has the target as an iframe on the same page.

What is the easier way to automatically fill the iframe with the
required new web page without having to get the user to click on the
link first.

- the content of the hyperlink are set in code based on user input...

<asp:HyperLink
ID="hyperlinktoGoogleMaps"
runat="server"
Width="450px"
Target="MapFrame">
Click here to view your house
</asp:HyperLink><br />

- this frame is filled when the user clicks the hyperlink, but I would
like it automatically filled server side.

<iframe scrolling=no
frameborder=no
marginwidth=0
marginheight=0
id="MapFrame"
name="MapFrame"
width="480"
height="480">
</iframe>
 
B

bruce barker

set the iframe src to the url you'd put in the hyperlink.

<iframe src="<%=GetIframeUrl()%>">

where GetIframeUrl is a method return the url string

-- bruce (sqlwork.com)
 
P

pb

set the iframe src to the url you'd put in the hyperlink.

<iframe src="<%=GetIframeUrl()%>">

where GetIframeUrl is a method return the url string

-- bruce (sqlwork.com)










- Show quoted text -

Thanks bruce, I tried that but it doesn't seem to do anything. Am I
missing something?

<iframe
src="<%# GetMapUrl()%>"
runat=server
</iframe>


Function GetMapUrl() As String

GetMapUrl = "WWW.WHATEVER"

End Function
 
P

pb

You haven't closed your iframe opener tag.

Doesn't your getmapurl function need to "return" the string? (I come from a
classic ASP background but predominantly write in C# now, so not sure...)

--
Best regards,
Dave Colliver.http://www.AshfieldFOCUS.com
~~http://www.FOCUSPortals.com- Local franchises available











- Show quoted text -

Thanks David & Bruce for the responses.

I had closed the tag - just missed it when copying a reduced version
of the code to post it here. The function works the same eitherway,
with or without a return.

I still don't get anything being filled in the frame though.

Phil
 
P

pb

Thanks David & Bruce for the responses.

I had closed the tag - just missed it when copying a reduced version
of the code to post it here. The function works the same eitherway,
with or without a return.

I still don't get anything being filled in the frame though.

Phil- Hide quoted text -

- Show quoted text -


I've narrowed this down to my lack of understanding of how to return a
value from the function - I've only a VB6 background.
The following code demonstrates what I am trying to achieve. The fact
that hyp1 doesn't work means that NavigateUrl="<%# GetUrl()%>" is not
doing what I want it to do.

Please could someone tell me the obvious error? Much appreciated.

Cheers,

Phil

<%-- these dont work--%>
<iframe
src="<%# GetUrl()%>"
runat=server
frameborder=yes
name = "myframe"
width="200"
height="200">
</iframe>

<BR />

<asp:HyperLink
ID="hyp1"
runat="server"
Width="450px"
Target="myframe"
NavigateUrl= said:
Click here to fill the frame
</asp:HyperLink>

<br />

<%--this works --%>
<asp:HyperLink
ID="hyp2"
runat="server"
Width="450px"
Target="myframe"
NavigateUrl="HTTP://WWW.GOOGLE.COM"
Click here to fill the frame
</asp:HyperLink><br />

code behind...

Function GetUrl() As String
Return "http://www.google.com"
End Function
 
D

David

Actually, I think I have just worked it out...

<iframe
src="<%# GetUrl()%>"
runat=server
frameborder=yes
name = "myframe"
width="200"
height="200">
</iframe>

Give your iframe an ID (YourIFrameID here for demo)

Reference the iframe in your codebehind...

proected System.Web.HtmlControls.iframe YourIFrameID; // I might have got
the syntax slightly wrong.

Then in your event, i.e. Page_Load

YourFrameID.src = "http://www.google.com"; // Quotes around URL may get
lost in translation...

Remove the src attribute completely from your iframe.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top