简体   繁体   English

iFrame在asp AjaxToolkit TabContainer中加载两次

[英]iFrame loading twice in asp AjaxToolkit TabContainer

am using asp AjaxToolkit in my prjoect as below asp.net C# code. 我在我的prjoect中使用asp AjaxToolkit ,如下面的asp.net C#代码。

<asp:UpdatePanel ID="UpdatePanelDemo" runat="server">
        <ContentTemplate>
            <ajax:TabContainer ID="tabMessage" runat="server" ActiveTabIndex="1" AutoPostBack="true"
                OnActiveTabChanged="tabMessage_ActiveTabChanged" CssClass="ajax__tab_blueGrad-theme">
                <ajax:TabPanel ID="TabMCompose" runat="server">
                    <HeaderTemplate>
                        <span style="padding-left: 5px; padding-right: 5px;">Compose </span>
                    </HeaderTemplate>
                    <ContentTemplate>
                    This Text not flickering or not loading twice // ***** 
                        <iframe id="IFrmCompose" runat="server" scrolling="no" frameborder="0" height="400px"
                            width="100%"></iframe>
                    </ContentTemplate>
                </ajax:TabPanel>
                <ajax:TabPanel ID="tabMInbox" runat="server">
                    <HeaderTemplate>
                        <span style="padding-left: 5px; padding-right: 5px;">Inbox (<span id="SpnIn" runat="server"></span>)</span>
                    </HeaderTemplate>
                    <ContentTemplate>
                        <iframe id="IFrmInbox" runat="server" scrolling="no" frameborder="0" height="400px"
                            width="100%"></iframe>
                    </ContentTemplate>
                </ajax:TabPanel>
            </ajax:TabContainer>
        </ContentTemplate>
   </asp:UpdatePanel>

Problem: When I use iFrame inside the ajax TabContainer and when the user moves from 1st Tab to 2nd Tab, it seems that the page load twice and iFrame load twice or it flickers but the text above the iFrame as shown above (' This Text not flickering or not loading twice ') is not flickering. 问题:当我在ajax TabContainer使用iFrame并且当用户从1st Tab移动到2nd Tab时,似乎页面加载两次并且iFrame加载两次或者它闪烁但是iFrame上方的文本如上所示(' This Text not闪烁或不加载两次 ')没有闪烁。

It seems there is some problem with iFrame and Ajax TabContainer . 似乎iFrameAjax TabContainer存在一些问题。

Please give me suggestion why this happens. 请告诉我为什么会这样。

Thanks. 谢谢。

Not 100% sure because there is no codebehind attached, but it looks like a ViewState issue. 不是100%肯定,因为没有附加代码隐藏,但它看起来像一个ViewState问题。 Since you are not setting the IFrame SRC in the repeater template, the page init will first set the IFrame empty and then re-set the URL even if it not changed (causing it to flicker). 由于您没有在转发器模板中设置IFrame SRC,因此页面init将首先将IFrame设置为空,然后重新设置URL,即使它未更改(导致其闪烁)。

Suggestion: Persist the URL in ViewState or other when a tab is changed, and set it in the repeater template to the persisted value. 建议:更改选项卡时,在ViewState或其他URL中保留URL,并将其在转发器模板中设置为持久值。 Always set any empty frame SRC to "about:blank" to avoid unnecessary loading and to reliably detect changes. 始终将任何空框架SRC设置为“about:blank”以避免不必要的加载并可靠地检测更改。

Just a side note: in a way you are doing the same thing twice - with UpdatePanels/Ajax Controls you do not need IFrames, the contents of your tab should retrieved via an AJAX call thus making the IFrames obsolete. 只是一个注意事项:在某种程度上,你做两次相同的事情 - 使用UpdatePanels / Ajax控件你不需要IFrames,你的选项卡的内容应该通过AJAX调用检索,从而使IFrames过时。

Not 100% sure because there is no codebehind attached, but it looks like a ViewState issue. 不是100%肯定,因为没有附加代码隐藏,但它看起来像一个ViewState问题。 Page reload maybe the reason of the behavior 页面重新加载可能是行为的原因

if(!IsPostback) BindIt(); if(!IsPostback)BindIt();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM