我想实现这样的功能:
提交时在服务器端保存整个html页面的信息.
我想viewState可以保存页面状态.那么在用户提交时,在服务器端拦截服务器端向客户端发送的这个具有用户信息状态的页面.就可以实现保存。不知道这样的想法对不对?具体如何实现呢?
不够分可再加

解决方案 »

  1.   

    为什么要“提交时在服务器端保存整个html页面的信息”?
      

  2.   

    <script>
    function aa()
    {
    document.all.b2.value=document.body.innerHTML;//把整个html页面的信息保存在一个不可见的文本框里,
    document.all.b1.click();//提交
    }
    </script>
    <input onclick=aa()   ....   ><!-- 触发js -->
    <asp:button id="Log" runat="server" Width="0px"><!-- 真正的提交按钮 -->
    <asp:TextBox id="b2" width="0" runat="server" ...cs部分
    .....b2.Text.Value为你要的结果。
    主要是你表述不清晰,如果我理解有误请说明白
      

  3.   

    写错了 更正<script>
    function aa()
    {
    document.all.b2.value=document.body.innerHTML;//把整个html页面的信息保存在一个不可见的文本框里,
    document.all.b1.click();//提交
    }
    </script>
    <input onclick=aa()   ....   ><!-- 触发js -->
    <asp:button id="b1" runat="server" Width="0px"><!-- 真正的提交按钮 -->
    <asp:TextBox id="b2" width="0" runat="server" ...cs部分
    .....
    private void b1_Click(object sender, System.EventArgs e)
    {
    //b2.Text.Value为你要的结果。 }主要是你表述不清晰,如果我理解有误请说明白
      

  4.   

    楼上兄弟的做法我早就想过。只是这样不能得到当前页面的信息,只能得到html的内容。不能得到用户输入的信息。如要得到用户输的信息的话。要提交两次才行。固这不是最好的办法
      

  5.   

    早就想过你做过么?想和做不一样的  你的代码和我一摸一样么注意每个细节 我怎么能得到文本框内信息
    <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebApplication1.WebForm1" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    <title>WebForm1</title>
    <script>
    function aa()
    {
    document.all.b2.value=document.body.innerHTML;
    document.all.Button1.click();
    }
    </script>
    </HEAD>
    <body MS_POSITIONING="GridLayout">
    <form id="Form1" method="post" runat="server">
    <FONT face="宋体">
    <asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 16px; POSITION: absolute; TOP: 32px" runat="server"></asp:TextBox>
    <asp:Button id="Button1" style="Z-INDEX: 102; LEFT: 312px; POSITION: absolute; TOP: 32px" runat="server"
    Text="Button"></asp:Button><INPUT style="Z-INDEX: 103; LEFT: 176px; POSITION: absolute; TOP: 32px" type="button" value="Button111111"
    onclick="aa()"></FONT>
    <asp:TextBox id="b2" style="Z-INDEX: 104; LEFT: 16px; POSITION: absolute; TOP: 64px" runat="server"
    TextMode="MultiLine" Height="224px" Width="376px"></asp:TextBox>
    </form>
    </body>
    </HTML>
      

  6.   

    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;namespace WebApplication1
    {
    /// <summary>
    /// WebForm1 的摘要说明。
    /// </summary>
    public class WebForm1 : System.Web.UI.Page
    {
    protected System.Web.UI.WebControls.TextBox TextBox1;
    protected System.Web.UI.WebControls.TextBox b2;
    protected System.Web.UI.WebControls.Button Button1;

    private void Page_Load(object sender, System.EventArgs e)
    {
    // 在此处放置用户代码以初始化页面
    } #region Web 窗体设计器生成的代码
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {    
    this.Button1.Click += new System.EventHandler(this.Button1_Click);
    this.Load += new System.EventHandler(this.Page_Load); }
    #endregion private void Button1_Click(object sender, System.EventArgs e)
    {
    Response.Write(b2.Text.ToString());
    }
    }
    }
    //代码自己运行  注意看><INPUT id=TextBox1 style="Z-INDEX: 101; LEFT: 16px; POSITION: absolute; TOP: 32px" value=   此处有结果的
      

  7.   

    把Button1宽度设为0  不能直接隐藏 否则报错  只能设为0 变相隐藏
      

  8.   

    呵。。想的和做出来的果然不一样..就连我现在的程序都是提交两次用的。我原来输入了信息以后查看源文件。看到html代码没有变。我还以为那样不可行。原来今天一试。才知道是可行的。我还把原来的所有控件都变成了服务器端控件.弄得麻烦得很。现在这样一改。方便多了。呵呵。。不好意思。刚才看电影。现在给分。感谢21aspnet