outcast_fr
Messages postés11Date d'inscriptionjeudi 10 novembre 2005StatutMembreDernière intervention11 avril 2006
-
7 mars 2006 à 09:16
outcast_fr
Messages postés11Date d'inscriptionjeudi 10 novembre 2005StatutMembreDernière intervention11 avril 2006
-
7 mars 2006 à 12:30
Bonjour,
j'ai créé un petit custom web control (pas de user control) composé d'un label et d'un bouton.
Mon but c'est de récupérer l'événement associé au bouton.
J'ai donc suivi un tutoriel, mais sans réel succès.
Voici le code :
Code:,
----
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Drawing;
namespace EAC_WebControls
{
/// <summary>
/// Summary description for EAC_WebControls.
/// </summary>
[DefaultProperty("Text"),
ToolboxData("<{0}:HeadWebPage runat=server></{0}:HeadWebPage>")]
public class HeadWebPage : System.Web.UI.WebControls.WebControl
{
private string text;
private Button myButton = new Button();
[Bindable(true),
Category("Attributs WebControl"),
Description("Texte de définition."),
DefaultValue("")]
public string Text
{
get
{
return text;
}
set
{
text = value;
}
}
//-----------------------------------------------------------------------
//Déclaration des délégués
public delegate void ValidButtonClickHandler(object sender, EventArgs e);
//Déclaration des événements qui utilisent ces délégués
[Category("Action"),
Browsable(true),
Description("Evénement associé au bouton de validation.")]
public event ValidButtonClickHandler BoutonValidClick;
public virtual void OnValidButtonClick(EventArgs e)
{
if (BoutonValidClick != null)
{
BoutonValidClick(this, e);
}
}
public void ButtonValid_Click(object sender, EventArgs e)
{
OnValidButtonClick(e);
}
//-----------------------------------------------------------------------
/// <summary>
/// Render this control to the output parameter specified.
/// </summary>
/// The HTML writer to write out to
[Bindable(true),
Category("Attributs WebControl"),
Description("Texte du Label."),
DefaultValue("")]
public string TexteLabel
{
get { return _Text; }
set { _Text = value; }
}
//-----------------------------------------------------------------------
//Déclaration des délégués
public delegate void ValidButtonClickHandler(object sender, EventArgs e);
//Déclaration des événements qui utilisent ces délégués
[Category("Action"),
Browsable(true),
Description("Evénement associé au bouton de validation.")]
public event EventHandler Click;
public void OnClick(EventArgs e)
{
EventHandler click = Click;
if (click != null)
{
click(this, e);
}
}
public void ButtonValid_Click(object sender, EventArgs e)
{
this.OnClick(e);
}
//-----------------------------------------------------------------------
/// <summary>
/// Render this control to the output parameter specified.
/// </summary>
/// The HTML writer to write out to