【发布时间】:2011-02-27 08:35:41
【问题描述】:
我开始编写一些复杂的代码,然后意识到我的事件处理程序不起作用,所以我用事件处理程序超级简化了一个按钮。请看下面的代码,也许你能告诉我为什么它不触发?
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using System.Web.UI.WebControls;
namespace PrinterSolution
{
[Guid("60e54fde-01bd-482e-9e3b-85e0e73ae33d")]
public class ManageUsers : Microsoft.SharePoint.WebPartPages.WebPart
{
Button btnNew;
protected override void CreateChildControls()
{
btnNew = new Button();
btnNew.CommandName = "New";
btnNew.CommandArgument = "Argument";
btnNew.Command += new CommandEventHandler(btnNew_Command);
this.Controls.Add(btnNew);
}
void btnNew_Command(object sender, CommandEventArgs e)
{
ViewState["state"] = "newstate";
}
//protected override void OnLoad(EventArgs e)
//{
// this.EnsureChildControls();
//}
}
}
【问题讨论】:
标签: sharepoint event-handling web-parts