Ajax TabContainer在Postback上间歇性地消失

时间:2013-01-29 13:53:30

标签: c# javascript jquery asp.net css

我正在使用C#ASP.net开发GIS Web应用程序(映射)。

我有一个Ajax TabContainer,它包含几个带桌子的TabPanel。该表包含其他内容,例如地图窗口,比例尺等(均来自ESRI WebAdf工具包)。

这是我的桌子的精简版,没有其他内容......

<table id="MainTable>

<tr>
<td>
   <ajax:TabContainer runat="server" ActiveTabIndex="0" id="TabContainer"  CssClass="ajax__tab_xp">  

    <ajax:TabPanel runat="server" HeaderText="Online Mapping Service" ID="TabPanel1">

</ajax:TabPanel>

<ajax:TabPanel ID="TabPanel2" runat="server" HeaderText="Postcode">


    </ajax:TabPanel>

    <ajax:TabPanel ID="TabPanel3" runat="server" HeaderText="Coordinates">
        <ContentTemplate>                                      



  </ajax:TabPanel>

   </ajax:TabContainer> 

  </td>
  </tr>

  </table>

在运行时回发时,我的Tabcontainer有时会消失。此问题不是特定于浏览器的。

到目前为止,我已经尝试过没有成功......

  1. 使用TabContainer的相对定位设置Z-Index
  2. 包含一个JQuery脚本以“显示”TabContainer ...

        <script type="text/javascript" language="javascript">
    
        $(document).ready(function() {
        $("#TabContainer").show();
    
        });
    
       </script>
    
  3. 是否有一些C#我可以在后面的代码中包含?...

    Public void page_Load(object sender, EventArgs e)
    {
       TabContainer.show()
    }
    

    相当新的编程并试图找出如何“总是显示”或“总是在顶上”TabContainer。

    由于

2 个答案:

答案 0 :(得分:0)

我不确定这是否是因为您在将代码发布到此处之前清理了代码但是您缺少标记。

您的aspx上的代码应如下所示:

<AjaxToolkit:TabContainer ID="TabContainer" runat="server">
    <AjaxToolkit:TabPanel ID="TabPanel1" runat="server">
        <ContentTemplate>
            Your asp/html code goes here
        </ContentTemplate>
    </AjaxToolkit:TabPanel>
 </AjaxToolkit:TabContainer>

答案 1 :(得分:0)

好的,排序了。 AJAX工具包存在一个问题,即没有回发客户端...

<script language="javascript" type="text/javascript">

        // Solution to sys.invalidoperationexception bug
        Sys.Application.initialize = function Sys$_Application$initialize() {
            if (!this._initialized && !this._initializing) {
                this._initializing = true;
                var loadMethodSet = false;
                var initializeDelegate = Function.createDelegate(this, this._doInitialize);
                if (document.addEventListener) {
                    loadMethodSet = true;
                    document.addEventListener("DOMContentLoaded", initializeDelegate, false);
                }
                if (/WebKit/i.test(navigator.userAgent)) {
                    loadMethodSet = true;
                    this._load_timer = setInterval(function() {
                        if (/loaded|complete/.test(document.readyState)) {
                            initializeDelegate();
                        }
                    }, 10);
                }
                else {
                    /*@cc_on@*/
                    /*@if (@_win32)
                    loadMethodSet = true;
                    document.write("<script id=__ie_onload defer src=BLOCKED SCRIPTvoid(0)><\/scr" + "ipt>");
                    var deferScript = document.getElementById("__ie_onload");
                    if (deferScript) {
                        deferScript.onreadystatechange = function() {
                            if (this.readyState == "complete") {
                                initializeDelegate();
                            }
                        };
                    }
                    /*@end@*/
                }

                // only if no other method will execute initializeDelegate is
                // it wired to the window's load method.
                if (!loadMethodSet) {
                    $addHandler(window, "load", initializeDelegate);
                }
            }
        }
        Sys.Application._doInitialize = function Sys$_Application$_doInitialize() {
            if (this._load_timer !== null) {
                clearInterval(this._load_timer);
                this._load_timer = null;
            }

            Sys._Application.callBaseMethod(this, 'initialize');

            var handler = this.get_events().getHandler("init");
            if (handler) {
                this.beginCreateComponents();
                handler(this, Sys.EventArgs.Empty);
                this.endCreateComponents();
            }
            this.raiseLoad();
            this._initializing = false;
        }

        Sys.Application._loadHandler = function Sys$_Application$_loadHandler() {
            if (this._loadHandlerDelegate) {
                Sys.UI.DomEvent.removeHandler(window, "load",
                  this._loadHandlerDelegate);
                this._loadHandlerDelegate = null;
            }
            this._initializing = true;
            this._doInitialize();
        }         

</script>