1

我在我的 aspx 文件上创建了一个 TabPanel。在后面的代码中,我动态创建:其中的选项卡以及每个选项卡中的 HtmlEditor。我还在每个选项卡上创建了一个侦听器,这样当它们被激活或显示时,该选项卡中的 HtmlEditor 就会获得焦点。

当我执行程序时,我看到选项卡已在我的 TabPanel 上创建。但是在网页准备好使用之前,会出现一个错误,指出侦听器中的对象 ID 未定义。所以监听器不起作用,页面没有完全加载。

奇怪的是,如果我直接在我的 aspx 文件中添加一个选项卡,在我的选项卡面板中添加一个选项卡,并使用侦听器加载我的动态选项卡的其余部分:html 编辑器的所有 Id 都被识别,并且所有侦听器都可以正常工作. 除了第一个选项卡外,witch 没有侦听器,并且在这种情况下不是动态创建的。

我的理论是,TabPanel 的索引 0 处的选项卡似乎在 HtmlEditor 控件的 ID 保存到页面之前启动了 Activate() 或 Show() 的侦听器。

所以我想知道我错过了什么以及如何将侦听器(激活或显示)放在 Tabpanel 中的每个选项卡上,这将触发该选项卡内控件的焦点方法。当然,我想动态生成我的所有标签。

你能帮助我吗 ?

我希望我足够清楚。

这是我的Default.aspx页面:

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>

<script runat="server"> </script>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Page sans titre</title>
</head>
<body runat="server">
              <ext:ScriptManager ID="CooliteScriptManager" runat="server" QuickTips="true" ScriptAdapter="Ext">
        </ext:ScriptManager>

<form id="form" runat = "server">
       <ext:Panel ID="PnFiche" runat="server" Border="false" Header="false" Frame="false"
                AutoScroll="true" BodyStyle="padding: 10px; text-align: left;">
                <Body>
                   <ext:FormLayout ID="FormLayout1" runat="server" LabelWidth="150">
                    <ext:Anchor runat="server">
                        <ext:MultiField runat="server" FieldLabel="Indications / but de l'analyse" >
                            <Fields>
                                <ext:FormPanel runat="server" Title="Indications / but de l'analyse" Width="1000" Collapsible="true">
                                    <Body>
                                        <ext:TabPanel ID="TpIndications" runat="server" Width="1000" Height="250" EnableTabScroll="true">     


                                        </ext:TabPanel>
                                    </Body>
                                </ext:FormPanel>
                            </Fields>
                        </ext:MultiField>
                    </ext:Anchor>
                    </ext:FormLayout>
                </Body>
       </ext:Panel>
       </form>

</body>
</html>

这是我的Default.aspx.cs页面:

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using Coolite.Ext.Web;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        GenerateObjectTabPanel(TpIndications, "French", "Indication", null);
        GenerateObjectTabPanel(TpIndications, "English", "Indication", null);
    }

    private void GenerateObjectTabPanel(TabPanel theTabPanel, String theLanguage, String suffixeID, String TextToReplace)
    {
        HtmlEditor TheHtmlEditor = new HtmlEditor();
        TheHtmlEditor.ID = "Editeur_HTML_" + suffixeID + "_" + theLanguage;
        TheHtmlEditor.Height = 250;
        TheHtmlEditor.Width = 1000;

        if (!string.IsNullOrEmpty(TextToReplace))
        {
            TheHtmlEditor.Text = TextToReplace;
        }

        Tab TheTab = new Tab("Tab_" + suffixeID + "_" + theLanguage, theLanguage);
        TheTab.BodyControls.Add(TheHtmlEditor);
        TheTab.Listeners.Activate.Handler = "#{" + TheHtmlEditor.ID + "}.focus();";

        theTabPanel.Tabs.Add(TheTab);

    }
}

尝试使用已加载的一个选项卡修改default.aspx,并且侦听器工作正常(但我当然不希望这样,因为我希望我的所有选项卡都被动态加载):

 <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>

<script runat="server"> </script>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Page sans titre</title>
</head>
<body runat="server">
              <ext:ScriptManager ID="CooliteScriptManager" runat="server" QuickTips="true" ScriptAdapter="Ext">
        </ext:ScriptManager>

<form id="form" runat = "server">
       <ext:Panel ID="PnFiche" runat="server" Border="false" Header="false" Frame="false"
                AutoScroll="true" BodyStyle="padding: 10px; text-align: left;">
                <Body>
                   <ext:FormLayout ID="FormLayout1" runat="server" LabelWidth="150">
                    <ext:Anchor runat="server">
                        <ext:MultiField runat="server" FieldLabel="Indications / but de l'analyse" >
                            <Fields>
                                <ext:FormPanel runat="server" Title="Indications / but de l'analyse" Width="1000" Collapsible="true">
                                    <Body>
                                        <ext:TabPanel ID="TpIndications" runat="server" Width="1000" Height="250" EnableTabScroll="true">     

                                                     <Tabs>
                                                        <ext:Tab ID="TI_fr_CA" runat="server" Height="250" Width="1000" Title="test">
                                                            <Body>
                                                                <ext:HtmlEditor ID="EI_fr_CA" runat="server" Height="250" Width="1000" Visible="true">
                                                                </ext:HtmlEditor>
                                                            </Body>

                                                        </ext:Tab>
                                                     </Tabs>
                                        </ext:TabPanel>
                                    </Body>
                                </ext:FormPanel>
                            </Fields>
                        </ext:MultiField>
                    </ext:Anchor>
                    </ext:FormLayout>
                </Body>
       </ext:Panel>
       </form>

</body>
</html>
4

1 回答 1

0

http://forums.ext.net/showthread.php?10857

于 2010-11-08T20:11:09.730 回答