在服務器端得到可編輯Iframe的HTML源代碼
2024-08-26 00:15:38
供稿:網友
下面的這個例子實現了在服務器端得到可編輯iframe的html源代碼非典功能。代碼很簡單,這里疾苦不多解釋了。代碼如下:
getiframehtml.axpx
<%@ page language="<a target="_blank">vb</a>" validaterequest=false autoeventwireup="false"
codebehind="getiframehtml.<a target="_blank">asp</a>x.vb" inherits="aspx<a 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開發資料庫,