我有一个带有以下代码的简单 webpart,但是当我单击“UnAcceptClick”中的按钮代码时不起作用。
我错过了什么或做错了什么?
public class simple_wp : WebPart
{
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
CreateControlHierarchy();
}
private void CreateControlHierarchy()
{
unAccept.Text = "Cancel";
unAccept.Click += new EventHandler(UnAcceptClick);
... some other code ... }
private void UnAcceptClick(object sender, EventArgs e)
{
... some code ...
}
protected override void CreateChildControls()
{
try
{
Controls.Add(unAccept); // button
}
catch (Exception ex)
{
Controls.Add(new LiteralControl(ex.ToString()));
}
} // # CreateChildControls #
}