开发者

How can I embed a static HTML page in a aspx page?

开发者 https://www.devze.com 2023-02-15 00:05 出处:网络
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 ASPXpage and have the ASPX

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. Tha开发者_如何学编程nks a lot!


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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消