u could try:
Server.urlEncode(yourstring)

解决方案 »

  1.   

    cannot reproduce your problem1. TestPost.aspx:<%@ Page language="c#" Codebehind="TestPost.aspx.cs" AutoEventWireup="false" Inherits="WebApplication3.TestPost" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
      <HEAD>
        <title>TestPost</title>
      </HEAD>
      <body>
        <form id="Form1" method="post" runat="server"><asp:TextBox id=TextBox1 runat="server" TextMode="MultiLine" Rows="5" Columns="20"></asp:TextBox><asp:Button id=btnSubmit runat="server" Text="Submit"></asp:Button>
         </form>
      </body>
    </HTML>2. TestPost.aspx.csusing System;
    using System.Collections;
    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;
    using System.IO;namespace WebApplication3
    {
    /// <summary>
    /// Summary description for TestPost.
    /// </summary>
    public class TestPost : System.Web.UI.Page
    {
    protected System.Web.UI.WebControls.TextBox TextBox1;
    protected System.Web.UI.WebControls.Button btnSubmit;

    private void Page_Load(object sender, System.EventArgs e)
    {
    // Put user code to initialize the page here
    } #region Web Form Designer generated code
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN: This call is required by the ASP.NET Web Form Designer.
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {    
    this.btnSubmit.Click += new System.EventHandler(this.btnSubmit_Click);
    this.Load += new System.EventHandler(this.Page_Load); }
    #endregion private void btnSubmit_Click(object sender, System.EventArgs e)
    {
    if (!TextBox1.Text.Equals(String.Empty))
    {
    StreamWriter sw = new StreamWriter(Server.MapPath("Test.txt"));
    sw.Write(TextBox1.Text);
    sw.Close();
    }
    }
    }
    }
    3. input:
    default:
       putchar(node->oper);
       return;
    }
    if (lpri > prior)
       putchar('(');
    Print(node->left, lpri);
    putchar(node->oper);
    4. Test.txt:
    default:
       putchar(node->oper);
       return;
    }
    if (lpri > prior)
       putchar('(');
    Print(node->left, lpri);
    putchar(node->oper);
      

  2.   

    if you input html, you might get errors in .NET 1.1, to resolve it, you can modify the aspx file<%@ Page validateRequest="false"  %>or modify the web.config:<configuration> 
      <system.web> 
        <pages validateRequest="false" /> 
      </system.web> 
    </configuration> 
      

  3.   

    to saucer(思归, MS .NET MVP):谢谢你给出详尽的代码和帮助
    我的程序和你给的只有一点差别
    sw.Write(TextBox1.Text); //你写的
    sw.WriteLine(TextBox1.Text);//我原来的
    但是这两个的效果是一样的,就是说,依然是错误随机的出现,提交几次后就会出现我列出的那些改动 至于什么时候会出错根本预测不到,大部分时候是正确的请问哪里可以找到关于asp.net表单提交原理细节的资料,也许是提交的过程中出的错
      

  4.   

    >>>>>也许是提交的过程中出的错Response.Write("**********<BR>" + TextBox1.Text + "********<BR>")what do you see? do you see the correct input??
      

  5.   

    提交结束后,TextBox里的文字也改变了,和保存在server端的文本文件里的错的一样
    我没有用response 看,因为我的输入太长了 大约 170 行,返回来也没有格式,找不到如果输入比较少的话,好像是不会出错的。。
      

  6.   

    i try Response.Write("**********<BR>" + TextBox1.Text + "********<BR>")then I find that  input has been changed as it is saved on server..
      

  7.   

    if you don't help yourself, how can you expect people to help you?Response.Write("**********<BR><PRE>" + TextBox1.Text + "</PRE>********<BR>")orResponse.Write("**********<BR>" + TextBox1.Text.Replace("\r\n","<BR>").Replace(" ", "&nbsp;") + "********<BR>")
      

  8.   

    get a tool to examine the http packets, for example, fromhttp://www.effetech.com/