小弟是想做动态网页,就是说我想让网页的主要内容是变化的,如何实现????????
请高手帮忙!!!!!!!

解决方案 »

  1.   

    just a sample: if(System.IO.File.Exists("d:\\siptest.log"))
                {
                    string tmp = System.IO.File.OpenText("d:\\siptest.log").ReadToEnd();
                    Response.Write(tmp);
                }
      

  2.   

    public void SetDatums(string Path,string Value)
    {
    if(!File.Exists(Path))
    {
    FileStream fs = System.IO.File.Create(Path);
    writer = new StreamWriter(fs,System.Text.Encoding.GetEncoding("GB2312"));
    writer.Write(Value);
    }

    }
      

  3.   

    public string GetDatums(string Path)
    {
    if(File.Exists(Path))
    {
    reader =new StreamReader(Path,System.Text.Encoding.GetEncoding("GB2312"));
    return reader.ReadToEnd();
    }
    else
    {
    return String.Empty;
    }
    }
      

  4.   

    给你一个读取文本的函数
    /// <summary>
    /// 读取文本
    /// </summary>
    /// <param name="filePath">要读取的文件路径及名称</param>
    /// <returns>返回该文本的全部内容</returns>
    public string myReadText(string filePath)
    {
    StreamReader myr = new StreamReader(filePath,System.Text.Encoding.Default);
    string mystr = "";
    mystr = myr.ReadToEnd();
    myr.Close();
    return(mystr);
    }/// <summary>
    /// 将无格式的文本处理成有格式的文本
    /// </summary>
    /// <param name="mystr">要处理的文本</param>
    /// <returns>返回带换行等格式的文本</returns>
    public string MyReplace(string mystr)
    {
    if(this.MyisNull(mystr))
    {
    return("&nbsp;");
    }
    else
    {
    mystr = mystr.Replace("\n\r","<br>");
    mystr = mystr.Replace("\r","<br>");
    mystr = mystr.Replace("\t","  ");
    return(mystr);
    }
    }
    需要在页面显示的时候如下(大意)
    this.Response.Write(MyReplace(myReadText(this.Server.MapPath("你的文本文件名")));
      

  5.   

    感动ing!!!!!!!
    谢谢大家!!!!!!
    十分感谢!!!!!!
      

  6.   

    String result; //你要的替换的文本
    String tmp;  //
    StringReader reader =new StringReader("../Mybook.txt")
    tmp =reader.ReadLine();
    result = tmp;
    while ( tmp <> "")
    {
         result += "#" + tmp;
         reader.ReadLine(); 
    }
      

  7.   

    十分感谢大家,小弟又有了新的问题,就是怎么控制读入的TXT文本文件的位置及格式?麻烦大家了!!!!!
      

  8.   

    謝謝樓上的諸位,學習ing!!
      

  9.   

    例如:CompareValidator验证控件!
      

  10.   

    就是怎么控制读入的TXT文本文件的位置及格式?
    ----------------
    你最好在页面上放一个控件,然后用表格控制此控件的位置即可.