1

I have a static HTML page complete with client-side scripts and css (both are included in the html). I was wondering if it would be possible to embed this HTML page into an ASPX page and have the ASPX page be able to respond to javascript events that are raised from within the static html document? Does asp.net provide a specific control for this or can I use a frame?

Any help would be great. Thanks a lot!

Nick
  • 19,198
  • 51
  • 185
  • 312

3 Answers3

1

Might be a little shabby but you should be able to do something like this

 <%@ Page Language="C#" %>
   <html>
   <body>
        <%         
          Response.WriteFile ("Yourfile.html")
        %>
        ...
        ...
        ...
   </body>
   </html>

If you html page already has <html/>, <body /> etc., you need to remove them.

EDIT:

The other option is to use a <asp:Literal /> and in the code-behind do this

this.Literal1.Text = -html-file-contents-

but i prefer the first method.

Bala R
  • 107,317
  • 23
  • 199
  • 210
  • So as far as you know I literally have to read the contents of the file into the aspx page? That's what Ill do if necessary. Thanks – Nick Mar 07 '11 at 02:35
  • @Nick there is no control to embed a HTML file. You can use an IFRAME but i don't think your aspx page and iframe can exchange events. `WriteFile()` is your best bet AFAIK. – Bala R Mar 07 '11 at 02:38
0

I would do this with an IFrame if both the ASPX page and the HTML is coming from the same domain. Otherwise, the security restrictions are too much.

Then you can do things like window.frames[myframe].document

Other details can be found in the answer to another question here.

Community
  • 1
  • 1
JBrooks
  • 9,901
  • 2
  • 28
  • 32
0

If you put static HTML in your ASPX page, it will just render it as normal HTML. No controls necessary. Then you can use javascript to do whatever you want.

Erik Funkenbusch
  • 92,674
  • 28
  • 195
  • 291