Bonjour,
J'ai, dans un écran de saisie, un UserControl qui se comporte comme une TextBox (en plus de gérer les autocomplétions)
1 2 3 4 5 6 7 8 9 10
| <%@ Control Language="c#"
Inherits="Sic.Web._UserControls.UCCompletude"
CodeFile="UCCompletude.ascx.cs" %>
<script type="text/javascript" src="../@UserControls/completion.js"></script>
<asp:TextBox id="TextBoxSaisieLibelle" runat="server" />
<input id="TextBoxSaisieCode" runat="server" type="hidden" />
<input id="TextBoxListeCodes" runat="server" type="hidden" />
<input id="TextBoxListeLibelles" runat="server" type="hidden" /> |
Dans le code ça donne ça
<uc1:UCCompletude ID="TxtCommune" runat="server" AutoPostBack="true" MaxLength="35" Width="140px" />
Avant, ce champ était un TextBox, et je gérais l'événement OnTextChanged en appelant une fonction TxtCommune_Changed.
Ma question: Comment faire pour que ce soit géré dans le UserControl?
J'ai réussi à "passer" des propriétés de TextBox simples dans le UserControl comme ceci:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| public partial class UCCompletude : System.Web.UI.UserControl
{
[....]
// propriété Width
public Unit Width
{
get { return this.TextBoxSaisieLibelle.Width; }
set { this.TextBoxSaisieLibelle.Width = value; }
}
// propriété MaxLength
public int MaxLength
{
get { return this.TextBoxSaisieLibelle.MaxLength; }
set { this.TextBoxSaisieLibelle.MaxLength = value; }
}
// propriété AutoPostBack
public bool AutoPostBack
{
get { return this.TextBoxSaisieLibelle.AutoPostBack; }
set { this.TextBoxSaisieLibelle.AutoPostBack = value; }
}
} |
Mais je ne sais pas comment faire pour un événement... 
Si vous pouviez éclairer ma faible lanterne, ça serait super !
Partager