我在 aspx 页面上的工具栏按钮有问题。我用来仅在协议页面中再渲染 2 个按钮的方法如下。我仅在协议页面上的工具栏上呈现 2 个按钮(活动,存档)。但是,当这本书被归档时,我需要隐藏它们。我试图通过检查 if (Entity.IsArchived == 0) 来做到这一点,但它在界面中给了我以下错误:
错误详情
你调用的对象是空的。
该方法的代码是:
protected override void OnPrepareButtons(SortedList<string, ImageButton> buttons)
{
// Activate button
ImageButton img = new ImageButton();
img.ID = "btnActivate";
img.AlternateText = "Activate";
img.Command += new CommandEventHandler(btnActivate_Click);
img.CommandName = "Activate";
img.ImageUrl = "~/Content/images/png/apply.png";
img.Width = Unit.Pixel(25);
img.Height = Unit.Pixel(25);
img.ToolTip = "Activate";
buttons.Add("Activate", img);
// Archive button
img = new ImageButton();
img.ID = "btnArchive";
img.AlternateText = "Archive";
img.Command += new CommandEventHandler(btnArchive_Click);
img.CommandName = "Archive";
img.ImageUrl = "~/Content/images/png/lock.png";
img.Width = Unit.Pixel(25);
img.Height = Unit.Pixel(25);
img.ToolTip = "Archive";
buttons.Add("Archive", img);
base.OnPrepareButtons(buttons);
}
知道如何处理这种情况吗?