
恩 我 发给你我做的 我运用的是视图状态
给你看看?? 你的那个第一个问题
---------------------------------------------------------
public partial class _Default : System.Web.UI.Page?
{
? ? ?? System.Collections.Specialized.StringCollection list = new System.Collections.Specialized.StringCollection();
? ? ?? public System.Collections.Specialized.StringCollection List
? ? ?? {
? ? ? ? ? ?? get { this.list = this.ViewState["Meth"] as System.Collections.Specialized.StringCollection;
? ? ? ? ? ? ? ? ? ? ? ? if (this.list == null)
? ? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? this.list = new System.Collections.Specialized.StringCollection();
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? this.ViewState["Meth"] = this.list;
? ? ? ? ? ? ? ? ? ? ? ? ? ?? }
? ? ? ? ? ? ? ? ? ? ? ? ?? return this.list;
? ? ? ? ? ? ? ? ? ?? }
? ? ? ? ? }
? protected void Page_Load(object sender, EventArgs e)
? {
? this.List.Clear();
? CreateBoxAndButton();
? }
? private void CreateBoxAndButton()
? {
? TextBox tbxA = new TextBox();
? TextBox tbxB = new TextBox();
? TextBox tbxC = new TextBox();
? LinkButton lbnOk = new LinkButton();
? lbnOk.Text = "O K";
? lbnOk.Click += new EventHandler(lbnOk_Click);
? tbxA.Text = "1";
? this.List.Add("1");
? this.List.Add("2");
? //用PlaceHoder添加控件
? this.PlaceHoder1.Controls.Add(tbxA);
? this.PlaceHoder1.Controls.Add(tbxB);
? this.PlaceHoder1.Controls.Add(tbxC);
? this.PlaceHoder1.Controls.Add(lbnOk);
? }
? void lbnOk_Click(object sender, EventArgs e)
? {
? //找出PlaceHoder1上的控件?
? TextBox tbxA = this.PlaceHoder1.Controls[0] as TextBox;
? TextBox tbxB = this.PlaceHoder1.Controls[1] as TextBox;
? TextBox tbxC = this.PlaceHoder1.Controls[2] as TextBox;
? ??
? int a = Convert.ToInt32( this.List[0]);
? int b = Convert.ToInt32(this.List[1]);
? string text = tbxB.Text;
? if (text !="")
? {
? int temp = Convert.ToInt32(tbxB.Text);
? if (b != temp)
? {
? this.List.Clear();
? int b2 = Convert.ToInt32(tbxB.Text);
? int c2 = b2 * 2;
? int a2 = b2 / 2;
? tbxA.Text = a2.ToString();
? this.List.Add(string.Format("{0}", a2));
? this.List.Add(string.Format("{0}", b2));
? tbxC.Text = string.Format("{0}", c2);
? }
? }
? else
? {
? tbxA.Text = string.Format("{0}", a);
? tbxB.Text = string.Format("{0}", b);
? tbxC.Text = string.Format("{0}",(b*2));
? }
? }
}