使用 UpdatePanel 和 ToolkitScriptManager 时,AjaxControlToolkit TabContainer ActiveTabChanged 事件会触发两次吗?

发布于 2024-09-05 04:14:15 字数 2401 浏览 3 评论 0原文

我最近升级了此配置:

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&#243;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 加载时,它会填充两个 组件。

  1. 加载列表 带有一些文本框,用户可以使用 可以填写并按下按钮 添加记录。
  2. 显示任何输入的信息。为了历史的目的。

奇怪的已知行为是,它实际上触发 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.

  1. <asp:DataGrid /> load a list
    with some text box, which the user
    may fill out and press a button to
    add records.
  2. <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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

踏雪无痕 2024-09-12 04:14:15

我无法解决这个问题,因为它来自该组件的内部机制。我不会穿过那片丛林。因此,我请设计师为我绘制了很酷的选项卡,并使用 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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文