Html page
Copy codeThe Code is as follows: <% @ Page Language = "C #" AutoEventWireup = "true" CodeFile = "Default. aspx. cs" Inherits = "_ Default"
ValidateRequest = "false" %>
<% @ Register Src = "UserControl/Ucone. ascx" TagName = "Ucone" TagPrefix = "uc1" %>
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> Html source code extraction (maintained) after Page Submission </title>
<Script type = "text/javascript">
Function getAllCode_IE (){
Document. getElementById ("hid_html" pai.value?document.doc umentElement. outerHTML;
}
Function getAllCode_FireFox (){
Return document. body. innerHTML. toString ();
}
</Script>
</Head>
<Body>
<Form id = "form1" runat = "server">
<Div>
<Uc1: Ucone ID = "Ucone1" runat = "server"/>
</Div>
</Form>
</Body>
</Html>
User ControlCopy codeThe Code is as follows: <% @ Control Language = "C #" AutoEventWireup = "true" CodeFile = "Ucone. ascx. cs" Inherits = "UserControl_Ucone" %>
<Asp: TextBox ID = "txtName" runat = "server"> </asp: TextBox>
<Asp: Button ID = "btnAdd" runat = "server" Text = "Add"/>
<Input type = "hidden" id = "hid_html" name = "hid_html"/>
<Div id = "div_inner_input" runat = "server">
</Div>
User Control Background:Copy codeThe Code is as follows: public partial class UserControl_Ucone: System. Web. UI. UserControl
{
Protected void Page_Load (object sender, EventArgs e)
{
This. btnAdd. Attributes. Add ("onclick", "return getAllCode_IE ();");
}
Protected override void OnInit (EventArgs e)
{
Base. OnInit (e );
This. btnAdd. Click + = new EventHandler (btnAdd_Click );
}
Void btnAdd_Click (object sender, EventArgs e)
{
This. div_inner_input.InnerText = Request. Form ["hid_html"]. ToString ();
}
}
By: Ruanyiniu (Ryan)