我尝试在动态创建的 RadDock 的关闭事件上更新一个简单的标签。到目前为止工作正常,Label 获得正确的值但没有更新它。
RadDock dock = new RadDock();
dock.DockMode = DockMode.Docked;
dock.UniqueName = Guid.NewGuid().ToString();
dock.ID = string.Format("RadDock{0}", dock.UniqueName);
dock.Title = slide.slideName;
dock.Text = string.Format("Added at {0}", DateTime.Now);
dock.Width = Unit.Pixel(300);
dock.AutoPostBack = true;
dock.CommandsAutoPostBack = true;
dock.Command += new DockCommandEventHandler(dock_Command);
...
void dock_Command(object sender, DockCommandEventArgs e)
{
Status.Text = "Removed " + ((RadDock)sender).Title + " " + ((RadDock)sender).Text;
}
我试图这样做:
RadAjaxManager1.AjaxSettings.AddAjaxSetting(dock, Status, null);
在创建码头时,但在运行时我得到一个 NullReference Excepetion。
在使用 RadAjaxManager 注册的 Button 上,它可以显示由 dock_command 分配的值。
protected void Button1_Click(object sender, EventArgs e)
{
Status.Text = Status.Text;
}
更新: RadAjaxManager 是使用 VS2008 的集成向导创建的。无法选择 Docks,因为它们是在运行时生成的。在后端它包含在 AutoCompletion 中,因此 NullReference 与 AjaxManager 本身无关。就像我说的,与 Button 配合使用效果很好。
<telerik:RadAjaxManager ID="RadAjaxManager1">
<telerik:AjaxSetting AjaxControlID="Button1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="Label1"></telerik:AjaxUpdatedControl>
</UpdatedControls>
</telerik:AjaxSetting>