首页 > 编程 > HTML > 正文

在服务器端得到可编辑Iframe的HTML源代码

2024-08-26 00:15:38
字体:
来源:转载
供稿:网友
   下面的这个例子实现了在服务器端得到可编辑iframe的html源代码非典功能。代码很简单,这里疾苦不多解释了。代码如下:
  
  getiframehtml.axpx
  
  <%@ page language="<a href="http://dev.21tx.com/language/vb/" target="_blank">vb</a>" validaterequest=false autoeventwireup="false"
   codebehind="getiframehtml.<a href="http://dev.21tx.com/web/asp/" target="_blank">asp</a>x.vb" inherits="aspx<a href="http://dev.21tx.com/web/" target="_blank">web</a>.getiframehtml"%>
  <html>
   <body>
   <form id="frmmain" method="post" runat="server">
   <iframe id="ifrhtml" name="ifrhtml"></iframe>
   <br>
   <asp:button id="cmdsend" runat="server" text=" 提 交 "></asp:button>
   <input type="hidden" name="hidvalue">
   </form>
   <script>
   ifrhtml.document.designmode = "on";
   </script>
   </body>
  </html>
  
  
  getiframehtml.aspx.vb
  
  public class getiframehtml
   inherits system.web.ui.page
   protected withevents cmdsend as system.web.ui.webcontrols.button
   protected withevents ifrhtml as system.web.ui.htmlcontrols.htmlgenericcontrol
  
  #region " web form designer generated code "
  
   'this call is required by the web form designer.
   <system.diagnostics.debuggerstepthrough()> private sub initializecomponent()
  
   end sub
  
   private sub page_init(byval sender as system.object,_
   byval e as system.eventargs) handles mybase.init
   'codegen: this method call is required by the web form designer
   'do not modify it using the code editor.
   initializecomponent()
   end sub
  
  #end region
  
   private sub page_load(byval sender as system.object,_
   byval e as system.eventargs) handles mybase.load
   cmdsend.attributes.add("onclick", "document.frmmain.hidvalue.value" + _
   " = ifrhtml.document.body.innerhtml;")
   end sub
  
  
   private sub cmdsubmit_click(byval sender as system.object,_
   byval e as system.eventargs) handles cmdsend.click
   dim strvalue as string
   strvalue = request.form("hidvalue")
   response.write(server.htmldecode(strvalue))
   end sub
  
  end class注册会员,创建你的web开发资料库,
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表