0
我有一個簡單的webpart,下面的代碼,但是當我點擊「UnAcceptClick」中的按鈕代碼時無法工作。OnClick事件在WebPart中不起作用
我失蹤或做錯了什麼?
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 #
}
謝謝很多=)你的答案的幫助,現在代碼工作=) – Nana