Ajax Control Toolkit自定义选项卡扩展器以关闭标签客户端
-
18-09-2020 - |
题
我试图编写一个ajax控制扩展器,可以修改ajax控件工具包生成generacicetagcode,以便在单击后,TabPanel
的标题在文本后的图像使用客户端脚本隐藏标签标题(没有回波)。我还希望能够在关闭选项卡时指定OnClientClose函数,该函数也调用。
我是新的ASP控制扩展器,到目前为止我跟随了[教程](
解决方案
我终于想到了我需要做的事情。对于对解决方案感兴趣的人:
-
为了扩展TabPanel控件,我必须通过覆盖我的extender的服务器代码(
OnResolveControlID
)中的ClosableTabPanelExtender.cs
方法来绕过我发布的错误。protected override void OnResolveControlID(ResolveControlEventArgs e) { // Get a reference to the outermost TabContainer that contains the TabPanel being extended. TabContainer tabContainer = (TabContainer)base.FindControl(OuterTabPanelID); if (tabContainer != null) { // Check to see if any of the tabs are the control we are looking form. foreach (TabPanel tab in tabContainer.Tabs) { if (tab.ID == e.ControlID) { e.Control = tab; return; } } // If none of the tabs are what we are looking for, search the contents of each tab. foreach (TabPanel tab in tabContainer.Tabs) { Control ctrl = tab.FindControl(e.ControlID); if (ctrl != null) return; } } }
-
对于扩展器的客户端行为脚本(以及服务器和客户端代码之间的交互,在这个MSDN页面很有帮助,并将为您节省很多麻烦。
不隶属于 StackOverflow