views:

78

answers:

1

i have aspx page which has to render .htm page how can it be done

if possible then i want added feature that is i want to call a JavaScript after that .htm page is rendered

pls help

+1  A: 

If you were to just serve the original file, you could:

Response.Clear();
Response.WriteFile(localPathToHtmFile);

As you instead want to modify it, and assuming you need to stick to the full file, then you'd have to do some light parsing of it to add the script you want ran when the page is loaded in the browser. Instead of using WriteFile, you'd write the modified string to the response.

Another option, if you can have that file only include the html inside the body, is to load it in a literal control. Then you have the regular options to send / have the intended script to be ran at page load.

eglasius
+1: i would add the html to the innerHtml of a span or div control.
slugster
i want my html to be on external file, because it may be different every time (it'll be at user side and user may change it) ie there are different different .htm template for the module on the .aspx page which is calling it (the .htm page)
dexter
@Allen you could still use any of the solutions in my answer depending if those are full files or not ... you just need to download from the external location - you can even cache the already modified version locally if that makes sense to your scenario.
eglasius
can you elaborate more on Response. Clear();
dexter
more answers please!!
dexter