Question

I'm trying to find out what my options are to inject a local html file's contents into a webpage. I have a Scheduled task that gets a list of .html files from a remote server and stores them on the local webserver, this I can't change.

How can I get the .html file injected into a webpage via code-behind? I have a Literal control on the page I can put the HTML in but whats the best way to get the html from the file? Filestream? Or put those files containing partial HTML into IIS and serve them somehow?

From my understanding of my requirements I can't use ajax or an iframe. Sooo ?

Was it helpful?

Solution

I think you need to parse the downloaded HTML file and get the part you want and then use Literal on the hosting webpage. You need to write a code in the code behind, by opening the corresponding file from the local directory, parse it if you need to and then set it like literal = htmlContent. It needs to happen during page load or you create a static page and do the injection before hand.

OTHER TIPS

Can you make the .html files available on the same local web server? If you can do this, then using Jquery you can load this .html file.

$('#loader').load('www.mywebserver.com/htmlrepository/test.html');

'loader' above is the id of the html element where the html file content is to be loaded. 'test.html' is the html file downloaded.

Check more on this here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top