Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / June 2007

Tip: Looking for answers? Try searching our database.

filling iframe with web page

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pb - 01 Jun 2007 23:43 GMT
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>
bruce barker - 02 Jun 2007 00:35 GMT
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)

> Hi all,
>
[quoted text clipped - 28 lines]
>                     height="480">
>            </iframe>
pb - 02 Jun 2007 13:56 GMT
> set the iframe src to the url you'd put in the hyperlink.
>
[quoted text clipped - 38 lines]
>
> - 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
David - 02 Jun 2007 19:08 GMT
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...)

Signature

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

>> set the iframe src to the url you'd put in the hyperlink.
>>
[quoted text clipped - 52 lines]
>
>    End Function
pb - 02 Jun 2007 22:39 GMT
On Jun 3, 4:08 am, "David"
<david.colliver.N...@revilloc.REMOVETHIS.com> wrote:
> You haven't closed your iframe opener tag.
>
[quoted text clipped - 64 lines]
>
> - 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
pb - 03 Jun 2007 00:22 GMT
> On Jun 3, 4:08 am, "David"
>
[quoted text clipped - 83 lines]
>
> - 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="<%# GetUrl()%>"
        >
        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
David - 03 Jun 2007 10:44 GMT
Perhaps someone can explain the difference of <%# and <%= to me (I am not
sure, but I thought that <%# was a databound value)

If it is databound, you might try in your page load, page.databind()
alternatively, try the <%=

Signature

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

>> On Jun 3, 4:08 am, "David"
>>
[quoted text clipped - 143 lines]
>        Return "http://www.google.com"
> End Function
David - 03 Jun 2007 10:55 GMT
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.

Signature

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

>> On Jun 3, 4:08 am, "David"
>>
[quoted text clipped - 143 lines]
>        Return "http://www.google.com"
> End Function

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.