我想检查方法中是否单击了按钮
我试过了,但它不工作
代码:
protected override void LoadViewState(object savedState)
{
base.LoadViewState(savedState);
//Here If (btnAddExperience_Click() is clicked)
{
GenerateControls();
}
GenerateControls1();
}
private void GenerateControls()
{
foreach (string i in NoOfControls)
{
VisaUserControl ctrl = (VisaUserControl)Page.LoadControl("VisaUserControl.ascx");
ctrl.ID = i;
this.rpt1.Controls.Add(ctrl);
rpt1.Controls.Add(new LiteralControl("<BR>"));
}
}
protected void btnAddVisa_Click(object sender, EventArgs e)
{
Button thisButton = (Button)sender;
List<string> temp = null;
var uc = (VisaUserControl)this.LoadControl(@"VisaUserControl.ascx");
string id = Guid.NewGuid().ToString();
uc.ID = id;
temp = NoOfControls;
temp.Add(id);
NoOfControls = temp;
rpt1.Controls.Add(uc);
rpt1.Controls.Add(new LiteralControl("<BR>"));
}
private void GenerateControls1()
{
foreach (string i in NoOfControls)
{
ExperienceUserControl ctrl = (ExperienceUserControl)Page.LoadControl("ExperienceUserControl.ascx");
ctrl.ID = i;
this.rpt1.Controls.Add(ctrl);
rpt2.Controls.Add(new LiteralControl("<BR>"));
}
}
protected void btnAddExperience_Click(object sender, EventArgs e)
{
List<string> temp = null;
var uc = (ExperienceUserControl)this.LoadControl(@"ExperienceUserControl.ascx");
string id = Guid.NewGuid().ToString();
uc.ID = id;
temp = NoOfControls;
temp.Add(id);
NoOfControls = temp;
rpt2.Controls.Add(uc);
rpt2.Controls.Add(new LiteralControl("<BR>"));
}
有任何想法吗?提前致谢