Charger des UserControl dynamiquement
Bonjour, j'ai un petit soucis avec la méthode qui permet de charger un UserControl dynamiquement.
Je vous explique vite fait :
- J'ai une 15 de UserControl , et j'en charge un lorsque j'effectué un clic sur un Treeview. Mon problème arrive au rendu HTML de la page, car il me génére devant tous les ID des champs input des "ctl04$" ou "ctl05$"
Voici un extrait d'UserControl que j'utilise :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| <%@ Control Language="VB" AutoEventWireup="false" CodeFile="AlarmeCentraleUserControl.ascx.vb" Inherits="UserControl_WebUserControl" %>
<table id="TableInfoEquipement" cellpadding="0" cellspacing="0" style="width: 530px" border="0">
<tr >
<td style="width: 40px"></td>
<td style="width: 130px; height: 30px">Libellé:</td>
<td style="width: 360px; height: 30px;">
<asp:TextBox ID="TB_libelle" runat="server" ReadOnly="True"></asp:TextBox></td>
</tr>
<tr >
<td style="width: 40px; height: 27px;"></td>
<td style="height: 27px">Marque:</td>
<td >
<asp:TextBox ID="TB_marque" runat="server" ReadOnly="True"></asp:TextBox></td>
</tr>
</table> |
Et voici mon la méthode pour charger l'UserControl
Code:
1 2 3 4 5 6
| Private Sub ChargerUserControl(ByVal pFamille As String, ByVal pType As String)
c_PlaceHolder.Controls.Clear()
RooterControl(pFamille, pType)
Dim header As Control = Page.LoadControl(Source)
c_PlaceHolder.Controls.Add(header)
End Sub |
Enfin voici le rendu HTML de la page ASP :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| <table id="TableInfoEquipement" cellpadding="0" cellspacing="0" style="width: 530px" border="0">
<tr >
<td style="width: 40px"></td>
<td style="width: 130px; height: 30px">Libellé:</td>
<td style="width: 360px; height: 30px;">
<input name="clt04$TB_libelle" type="text" value="ESSAI" readonly="readonly" id="UsrCtrl_TB_libelle" /></td>
</tr>
<tr >
<td style="width: 40px; height: 27px;"></td>
<td style="height: 27px">Marque:</td>
<td >
<input name="clt04$TB_marque" type="text" value="lkjldfj" readonly="readonly" id="UsrCtrl_TB_marque" /></td>
</tr>
</table> |
Je me demandais si c'était normal, et comment palier à ce problème ??