views:

77

answers:

4

I used to implement this above title by using iframe but now I dont want to use it any more I have some plans in my mind I need to implement them by opening an external page inside our asp.net page without using any iframe I have only simple aspx page with div tage and panel and some other serverside componants, I just want to know how I can do it without iframe ? I don't want to design new complex control but I am looking for some methods can do that for me.

I have to mention that I need to control area which is loaded by external site as the same as iframe but the difference is that iframe can not handled by ajax even you put iframe inside the update panel your page has refresh and postback while you are changing the src value programmatically (in c# code) so we have to design some others methods what is the solution ?

I thought I can make request an get some html and show into div but I couldn't to implement it.

A: 

Your direct request, "opening an external page inside our asp.net page without using any iframe" is not possible, by design.

You mention AJAX. You can use AJAX to load your page, remove the headers (or do that serverside) and replace the <body> tag with a <div> tag (or do that server side too). This way, you can place the contents of your page anywhere you like. As a container, I suggest you use a block level element, a <div> would suffice.

The only (!) problem here is: cross-site requests like this are not honored by browsers. You can solve this server-side by loading the page from elsewhere using WebRequest or similar means.

Abel
+4  A: 

You could

  1. Make a WebRequest on the server-side and then set the div's text to HTML returned
  2. You could make an invisible iFrame to make the request and then use JavaScript to grab the HTML from the iFrame and put it in a DIV. (EDIT: Comment suggests this won't work)

You can't generally make calls (like XmlHttpRequest) to external websites because of cross-site scripting issues.

Lou Franco
iirc, grabbing externally loaded HTML, not originating in the same domain, whether in an iframe or not, will not be honored by the browser, resulting in an empty string.
Abel
item 1 you said it is so nice but is it decrease my speed and performance can I load the page like loading webcontrol into panel or div in my c# code ?
kamiar3001
You can't really get around cross-site scripting unless you use an iframe or make the request on the server. What is wrong with just using an iframe in the normal way -- it's what it was designed for.
Lou Franco
@kamiar3001, just a note: depending on your infrastructure, it can also *increase* the speed and performance, assuming you supply proper server-side caching and have ample bandwidth and/or use Sounders' high performance methods liberally (check YSlow) to speed up your website.
Abel
A: 

there's no substitute for an iframe in your situation. you're not going to be able to make ajax requests to the other site due to security concerns. you could retrieve the contents of a single page server side and render it to the client but none of the functionality will be included, since the content is now running in the context of your own site.

lincolnk
you are completely wrong because if you have seen gmail site before you can see exactly which I want
kamiar3001
@kamiar3001: gmail uses a different technique to avoid the cross-site issues, namely: loading it through the same domain origin. This method is called "proxying" and works pretty well, however some functionality on the page will not always work as you expected (not even on gmail).
Abel
but you dont mention what technique does and why works pretty well how I can Implement with these tools that I have I think we can
kamiar3001
@kamiar3001: agreed (but I was not the writer of this answer). The technique is mentioned in about every post here: server side you get the HTML, and you send it to your client through AJAX means. Simple and right as rain, but a bit of work to set up and even more to get right.
Abel
A: 

Depends on where you'd like to merge the data. If you'd like to merge the data on the client browser, your only other option besides frames is to use Javascript/Ajax.

You can do a jQuery.ajax() on page load and use the html() method on a div to populate it with the textual result of that AJAX call.

Try to use as little of the WebForms control hierarchy and life-cycle as possible. It sounds like your problem can be fixed with AJAX if you don't mind the second request on page load.

If you would like to merge the content on the server side ( rarely the right thing to do ) you can use System.Net.HttpWebRequest to get and merge the data before returning it to the browser.

kervin