asp.net + iframe + dynamic url

Posted on 2005-03-30
Medium Priority
Last Modified: 2008-03-03
i have a usercontrol that has an iFrame, it pulls another page into the iframe, the problem is if i use the user control in a page in a different folder obviously the path has changed.  how can i get the path no matter what page i use the user control

I tired using the ~ hoping it would go the the parent folder and work its way down, but that didn't work

<iframe id="ifrmComments" name="ifrmComments"  src="WebForms/ViewOrderLogs.aspx"
 scrolling="auto" width="100%" height="130"></iframe>

works fine if i use the user control as in the same folder.

Question by:dkilby
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 11

Expert Comment

ID: 13668031



Accepted Solution

ovalsquare earned 2000 total points
ID: 13669113
Whenever you use the tilde character ("~"), you have to make sure that you run the control at server as in the following:

<iframe id="ifrmComments" runat="server" name="ifrmComments"  src="~/WebForms/ViewOrderLogs.aspx"
 scrolling="auto" width="100%" height="130"></iframe>

If you'd rather not deal with it that way, you can always just use a forward slash which always depicts the site root (which may or may not be your application root):

<iframe id="ifrmComments" name="ifrmComments"  src="/WebForms/ViewOrderLogs.aspx"
 scrolling="auto" width="100%" height="130"></iframe>

Of course, it won't work on your development machine if it's not Windows Server because your Site root and your application root will be different (because i.e. WinXP can only run one site at a time - typically Default Web Site, in which you set up different application roots i.e. http://localhost/MyWebSite, whereas when you post on a live server, you'll likely have the site root and application be one and the same. This isn't very clear, but you likely already know what I'm talking about. Let me know if you need more explanation on this point. There's a great tool out there called IIS Admin that you can use to set up multiple sites on a WinXP machine and quickly switch between them. This all goes away with Whidbey's (ASP.NET 2.0) built-in Web server...ahhhhh, Whidbey, how much longer do we have to wait ;-)



Expert Comment

ID: 13850843
I explained why his ~ wasn't working, as well as some other options, answering his request so it would be nice to get the points ;-)


Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses
Course of the Month9 days, 4 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question