3
我開始編碼一些複雜的事物,然後意識到我的事件處理程序不起作用,所以我使用事件處理程序簡化了一個按鈕。請看下面的代碼,也許你可以告訴我爲什麼它不會觸發?我的webpart事件處理不會在SharePoint中觸發
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();
//}
}
}