Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 6th, 2007, 08:24 PM
Authorized User
 
Join Date: Feb 2007
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using IFrames

I have been having a lot of trouble getting IFrames to work. Can someone show me how to use IFrame to embed a remote web page into the current aspx page?

 
Old March 7th, 2007, 08:37 AM
Registered User
 
Join Date: Mar 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Just put the code like this somewhere in your body:
<iframe id="Iframe1" src="http://www.wrox.com"
                    style="width:300px;height:300px;"></iframe>

or send more specific info about the problems


 
Old March 7th, 2007, 11:46 AM
Authorized User
 
Join Date: Feb 2007
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

oh yeah sorry I should have been more specific, I need to be able to change the page which is displayed programatically. Is there any way of accomplishing that? Effectively changing the src according to user input?

 
Old March 7th, 2007, 07:51 PM
Authorized User
 
Join Date: Mar 2007
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You do this:
<iframe id="Iframe1" src="<% getUrl() %>" style="width:300px;height:300px;"></iframe>
and then in your code behind
dim url as string
sub someClicky()
url = textbox1.text
end sub

public function getUrl()
return url
end function



 
Old March 8th, 2007, 08:14 PM
Authorized User
 
Join Date: Feb 2007
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have been trying that in C# and it doesnt seem to be working.
code behind:
protected string getUrl()
    {
        return Session["theUrl"].ToString();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Session["theUrl"] = "http://reuters.com";

    }

ASPX:
<iframe id="Iframe1" src="<% getUrl(); %>"
    style="width:729px;height:594px;"></iframe>

 
Old March 9th, 2007, 11:42 AM
Authorized User
 
Join Date: Mar 2007
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I will try it and paste the code. Just a minute.

 
Old March 9th, 2007, 12:02 PM
Authorized User
 
Join Date: Mar 2007
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by gobotsoup
 I have been trying that in C# and it doesnt seem to be working.
code behind:
protected string getUrl()
    {
        return Session["theUrl"].ToString();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Session["theUrl"] = "http://reuters.com";

    }

ASPX:
<iframe id="Iframe1" src="<% =getUrl(); %>"
    style="width:729px;height:594px;"></iframe>

Sorry I left out a small item that makes a HUGE difference. its:
src="<% =getUrl(); %>"

the = tells it to send the returned value, basically

Same as
src="<% response.write(getUrl()) %>"

Either will work.
I never use the ; inline in the aspx files either, but I dont program in c much, so im assuming you know what your doing there:)
ciao!

click

 
Old March 9th, 2007, 01:47 PM
Authorized User
 
Join Date: Feb 2007
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks A lot Works like a charm now!






Similar Threads
Thread Thread Starter Forum Replies Last Post
passing variables b/t iframes smys123 Javascript 1 July 2nd, 2007 04:30 PM
Using iframes to access history toddw607 ASP.NET 2.0 Basics 0 June 27th, 2007 03:51 PM
iframes Y_Ali Javascript 1 December 18th, 2006 07:41 AM
Iframes? Thagi ASP.NET 1.x and 2.0 Application Design 0 April 7th, 2006 07:34 AM
iframes?Do you know about it? help me then nerssi Javascript 4 September 25th, 2004 10:51 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.