我在我的aspx文件中創建了TabPanel。在我的代碼背後,我動態地創建了:它內部的標籤以及每個Tab中的HtmlEditor。我還在每個選項卡上創建了一個偵聽器,以便當它們被激活或顯示時,該選項卡中的HtmlEditor將獲得焦點。Ext.NET(Coolite)在Tabpanel中動態創建Tabs的監聽器沒有找到HTMLEditor的ID(對象未定義)
當我執行該程序時,我看到該選項卡已在我的TabPanel上創建。但是在網頁準備好使用之前,發生錯誤說明偵聽器中的對象Id未定義。所以偵聽器不工作,頁面不能完全加載。
奇怪的部分是,如果我直接在我的aspx文件中添加一個Tab在我的Tab面板中,並加載我的動態選項卡的其餘部分與偵聽器:HTML編輯器的所有ID都被識別,並且所有聽衆完美地工作。除了第一個選項卡,女巫沒有監聽者,並且在這種情況下沒有動態創建。
我的理論是,在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>