How to save the Page Status and output the source code of the Post form in asp.net

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.