Ext.NET (Coolite) dinamicamente creato ascoltatore di schede in un Tabpanel non trovare l'ID del HTMLEditor (oggetto non è definito)
-
29-09-2019 - |
Domanda
Ho creato un TabPanel sul mio file aspx. Nel mio codice dietro, creo in modo dinamico: le schede al suo interno e anche un HTMLEditor in ogni scheda. Ho anche creare un listener in ogni scheda, in modo che quando vengono attivati ??o spettacolo, la HTMLEditor in quella scheda ottenere la messa a fuoco.
Quando eseguo il programma, vedo che la scheda sono stati creati sulla mia TabPanel. Ma prima che la pagina web è pronto per l'uso, un errore si verificano dicendo che gli oggetti Id negli ascoltatori non è definito. Così l'ascoltatore non funziona e la pagina non si carica completamente.
La parte strana, è che, se aggiungo direttamente nel mio file aspx, una scheda nel mio pannello a schede, e caricare il resto della mia scheda dinamica con gli ascoltatori: Tutti vengono riconosciuti gli ID degli editor HTML, e tutto il ascoltatori funziona perfettamente. Fatta eccezione per la prima scheda, strega non hanno ascoltatore e non è stato creato in modo dinamico, in questo caso.
La mia teoria su questo, è che la linguetta in corrispondenza dell'indice 0 di un TabPanel sembra lauch l'ascoltatore di Attiva () o Mostra () prima della ID del controllo HTMLEditor è salvare la pagina.
Quindi mi chiedo quello che ho perso e come posso mettere ascoltatori (attivare o immagini) per ogni scheda in un Tabpanel che attiverà il metodo di messa a fuoco di un interno di controllo che Tab. E naturalmente voglio generare tutta la mia scheda in modo dinamico.
Mi potete aiutare?
Spero di essere stato abbastanza chiaro.
Ecco il mio 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>
Ecco il mio 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);
}
}
Prova a modificare la default.aspx con una scheda già caricato e l'ascoltatore funziona bene (ma naturalmente non voglio che, dal momento che voglio tutta la mia scheda da caricare in modo dinamico):
<%@ 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>