此链接可能会对您有所帮助。简而言之,它设置了一个Hidden
字段,然后在按钮 Submit Click 方法上从 iFrame 填充 HTML。
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="test.aspx.vb" Inherits="test"%>
<form id=frmMain method=post runat="server">
<iframe id=ifrHTML name=ifrHTML runat="server"></iframe>
<asp:Button id=cmdSend runat="server" Text="Send"></asp:Button>
<input type=hidden name=hidValue>
</form>
<script>
//Set the IFRame to Desing Mode.
ifrHTML.document.designMode = "on";
</script>
// Code Behind
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
cmdSubmit.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 cmdSubmit.Click
Dim strValue As String
strValue = Request.Form("hidValue")
End Sub