当前位置: 代码迷 >> ASP.NET >> LoadViewState不执行,为什么?解决方案
  详细解决方案

LoadViewState不执行,为什么?解决方案

热度:1537   发布时间:2013-02-25 00:00:00.0
LoadViewState不执行,为什么?
public class CartLoader : System.Web.UI.WebControls.WebControl
  {
  private string text;

  public string Text
  {
  get 
  {  
  return text;
  }
  set 
  {
  text = value;
  }
  }

  protected override void LoadViewState(object savedState)
  {
  text = savedState.ToString();
  }

  protected override object SaveViewState()
  {
  return text;
  }

  protected override void Render(HtmlTextWriter output)
  {
  output.Write("<input type= text id='txt_"+ this.UniqueID+"' value='"+Text+"' />");
  output.Write("<input type= submit id='" + this.UniqueID + "' value='324' />");
   
  }
  }

 一个简单的例子,想保存用户输入的值,但页面提交时LoadViewState没执行,所以值没了,怎么让LoadViewState执行??????

------解决方案--------------------------------------------------------
如果你覆盖一个父类方法,例如:
C# code
               protected override void abcd(......)         {             base.abcd(.....);            .........        }
  相关解决方案