• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 472
  • Last Modified:

asp.net + iframe + dynamic url

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.

Thanks
0
dkilby
Asked:
dkilby
  • 2
1 Solution
 
sachiekCommented:
"~" WILL TAKE TO ROOT

SO ACCORDINGLY YOU CAN TRY OUT.


SACHI
0
 
ovalsquareCommented:
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 ;-)

Ted

0
 
ovalsquareCommented:
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 ;-)

Ted
0

Featured Post

Industry Leaders: 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!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now