我在用户控件中写了几个方法(页面的加载、增加等等),我在页面中使用了用户控件,我想用用户控件中的方法怎么调用的我用的是new出来的方法:用户控件 ui=new 用户控件();
ui.方法();
问题:方法是可以调出来了,但是用户控件中的TextBox取值赋值的时候报错,没有实例化对象。这个是什么问题,有哪些方法可以解决这个问题呢,从调用解决?从实例化解决?求真相
ui.方法();
问题:方法是可以调出来了,但是用户控件中的TextBox取值赋值的时候报错,没有实例化对象。这个是什么问题,有哪些方法可以解决这个问题呢,从调用解决?从实例化解决?求真相
public string name
{
get {return TextBox1.Text; }
}
TextBox t=UserControl1.FindControl("TextBox1") as TextBox;
public event EventHandler BtnEvent;
private void Btn_Click(object sender, System.EventArgs e)
{
if (BtnEvent != null)
{
BtnEvent(sender,e);
}
}
override protected void OnInit(EventArgs e)
{
btn.BtnEvent += new EventHander(this.test);
}
private void A(object sender ,System.EventArgs e)
{
}