return;
     }
    }
   });
</script>
</asp:Content>



_4_IncrementalContent.aspx.cs文件代码如下:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
public partial class _4_IncrementalContent : System.Web.UI.Page
{
private static List<Comment> Comments;
    protected void Page_Load(object sender, EventArgs e)
    {
  if (!this.IsPostBack)
  {
   // 在第一次打开页面时清空所有Comments。
   // 古怪的用法,仅在这个示例时这么用。
   Comments = new List<Comment>();
   this.BindComments();
  }
    }
private void BindComments()
{
  this.Repeater1.DataSource = Comments;
  this.Repeater1.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
  Comment comment = new Comment();
  comment.Content = this.TextBox1.Text;
  comment.Time = DateTime.Now;
  // Comments.Add(comment);
  this.Repeater1.DataSource = new Comment[] { comment };
  // this.BindComments();
  this.Repeater1.DataBind();
}
}

相关文章: