views:

156

answers:

0

please help me. I started coding something complicated and then realized my event handlers don't work.. so i super simplified a button with an eventhandler... please see the code below and maybe you can tell me why it doesn't fire?

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();
        //}

    }
}