使用 UpdatePanel 和 ToolkitScriptManager 时,AjaxControlToolkit TabContainer ActiveTabChanged 事件会触发两次吗?
我最近升级了此配置:
ASP.NET 2.0
AjaxControlToolkit, 1.0.20229.0
System.Web.Extensions, Version=2.0.0.0
我
ASP.NET 3.5
System.Web.Extensions, Version=3.5.0.0
AjaxControlToolkit , Version=3.5.40412.0
具有以下结构:
<asp:ToolkitScriptManager ID="PageScriptManager" runat="server">
</asp:ToolkitScriptManager>
<asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="Always">
<ContentTemplate>
<ajaxToolkit:TabContainer
OnActiveTabChanged="TabContainerCarga_ActiveTabChanged"
AutoPostBack="True">
<ajaxToolkit:TabPanel
ID="tabRelatorios"
runat="server"
HeaderText="Relatórios">
<ContentTemplate>
<CustomUserControl:relatorios id="CustomControl" Visible="False" runat="server" />
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="CustomControl" />
</Triggers>
</ajaxToolkit:TabPanel>
<ajaxToolkit:TabPanel ... />
<ajaxToolkit:TabPanel ... />
<ajaxToolkit:TabPanel ... />
<ajaxToolkit:TabPanel ... />
所有这些都具有相同的第一个结构。在服务器端代码中,我有:
protected void TabContainerCarga_ActiveTabChanged(object sender, EventArgs e)
{
//handles TabPanels show/hide and fill up forms grids.
}
CustomControl 有一个网格,其中有一些回发来执行添加和删除记录等操作。当 CustomControl 加载时,它会填充两个
组件。
加载列表 带有一些文本框,用户可以使用 可以填写并按下按钮 添加记录。
显示任何输入的信息。为了历史的目的。
奇怪的已知行为是,它实际上触发 ActiveTabChanged 两次。第一次,它的行为就像我第一次加载 CustomControl 状态,然后他们去执行事件。
我无法使用我见过的一些解决方案,例如设置 isFormLoaded 标志,甚至无法触发 javascript postBack 函数。
我考虑在控件内放置一个以 ViewState 结构的 IsLoaded 标志。并在自定义控件内发生任何触发事件后重新启动它。
您对此有何看法?有什么解决方案吗?
I recently upgrade this configuration:
ASP.NET 2.0
AjaxControlToolkit, 1.0.20229.0
System.Web.Extensions, Version=2.0.0.0
To
ASP.NET 3.5
System.Web.Extensions, Version=3.5.0.0
AjaxControlToolkit , Version=3.5.40412.0
I have the following structure:
<asp:ToolkitScriptManager ID="PageScriptManager" runat="server">
</asp:ToolkitScriptManager>
<asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="Always">
<ContentTemplate>
<ajaxToolkit:TabContainer
OnActiveTabChanged="TabContainerCarga_ActiveTabChanged"
AutoPostBack="True">
<ajaxToolkit:TabPanel
ID="tabRelatorios"
runat="server"
HeaderText="Relatórios">
<ContentTemplate>
<CustomUserControl:relatorios id="CustomControl" Visible="False" runat="server" />
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="CustomControl" />
</Triggers>
</ajaxToolkit:TabPanel>
<ajaxToolkit:TabPanel ... />
<ajaxToolkit:TabPanel ... />
<ajaxToolkit:TabPanel ... />
<ajaxToolkit:TabPanel ... />
All the has the same first structure. At the serverside code, I have:
protected void TabContainerCarga_ActiveTabChanged(object sender, EventArgs e)
{
//handles TabPanels show/hide and fill up forms grids.
}
CustomControl has a grid which has some post-backs to perform operation like adding and removing records. When CustomControl loads it fills two <asp:DataGrid />
components.
<asp:DataGrid />
load a list
with some text box, which the user
may fill out and press a button to
add records.<asp:DataGrid
show any entered information. To history purposes.
/>
The strange known behavior is, it actually fire ActiveTabChanged twice. In the first time, it act like I'm loading the CustomControl state for the first time and them goes do the event.
I can't use some solution I've seen like set isFormLoaded flag or even fire a javascript postBack function.
I think about placing a IsLoaded flag structured in a ViewState inside the control. And restart it after any fired event inside the custom control.
What do you think about this and there is any solution arround?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我无法解决这个问题,因为它来自该组件的内部机制。我不会穿过那片丛林。因此,我请设计师为我绘制了很酷的选项卡,并使用 AJAX 和 Rest Services 风格编写了我自己的选项卡控件。就是这样!我现在想要的行为我已经实现了并且现在工作得很好;可控,并且将更少的 JavaScript 代码加载到客户端计算机中。别再用那个狗屎了!
I couldn't solve this problem because it comes from the internal mechanics of this component. I wouldn't go through that jungle. So I asked a designer to draw cool tabs for me and wrote my own tab control using AJAX and Rest Services style. That's it! The behavior I wanted now I have it and works pretty nice now; controllable and loads less JavaScript code into the client machine. Stop using that shit!