Create Events Handler
Code .NET SQL :: ASP.NET :: C#
Page 1 sur 1
Create Events Handler
Dans un User Control
Lancement event
Ecoute depuis page aspx
.............
/lancement
----------------------
//Abonnement
- Code:
public partial class PlantAccessList : System.Web.UI.UserControl
{
#region Properties
//Creation
public delegate void OnPlantIndexChanged();
public event OnPlantIndexChanged PlantIndexChanged;
#endregion
Lancement event
- Code:
protected void ddlPlant_SelectedIndexChanged(object sender, EventArgs e)
{
SessionManager.skSteeringUnitSelected = Convert.ToInt32(ddlPlant.SelectedValue);
if (PlantIndexChanged != null)
PlantIndexChanged();
}
Ecoute depuis page aspx
- Code:
public partial class Quantitative_CustomerDisturbances : MpmPage
{
protected PlantAccessList PlantAccessList1;
protected override void OnPreLoad(EventArgs e)
{
PlantAccessList1.PlantIndexChanged += new PlantAccessList.OnPlantIndexChanged(PlantAccessList1_PlantIndexChanged);
base.OnPreLoad(e);
}
void PlantAccessList1_PlantIndexChanged()
{
Response.Write(SessionManager.skSteeringUnitSelected.ToString());
}
}
- Code:
//Creation
public delegate void OnEditHandler();
public partial class EditPanel: WebControl
{
//utilisation
public event OnEditHandler OnEdit;
.............
/lancement
- Code:
OnEdit();
----------------------
//Abonnement
- Code:
EditPanel1.OnEdit += new Ppts.WebHelper.CustomControls.OnEditHandler(EditPanel1_OnEdit);
Avec parametres
Création de l'argument
+Construction event
Ajout de l'event
LAncement event avec parametre
+Construction event
- Code:
public class FilterEventArgs : EventArgs
{
public FilterEventArgs(int? idTypeSuite, int? idStatutSuite)
{
this.idTypeSuite = idTypeSuite;
this.idStatutSuite = idStatutSuite;
}
public readonly int? idTypeSuite;
public readonly int? idStatutSuite;
}
public delegate void FilterSanctionAfficherDelegate
(
FilterEventArgs filterEvent
);
Ajout de l'event
- Code:
public partial class FiltreSanctions : System.Web.UI.UserControl, INamingContainer
{
public event FilterSanctionAfficherDelegate FilterChanged;
#region Attributs
LAncement event avec parametre
- Code:
void RaiseFilterChanged()
{
if (FilterChanged != null)
{
int? idTypeSuite = null;
if (!string.IsNullOrEmpty(DropDownListTypeDeSuite.SelectedValue) && DropDownListTypeDeSuite.SelectedValue != "0")
idTypeSuite = Convert.ToInt32(DropDownListTypeDeSuite.SelectedValue);
int? idStatutSuite = null;
if (!string.IsNullOrEmpty(DropDownListStatut.SelectedValue) && DropDownListStatut.SelectedValue != "0")
idStatutSuite = Convert.ToInt32(DropDownListStatut.SelectedValue);
FilterEventArgs filterEvent = new FilterEventArgs(idTypeSuite, idStatutSuite);
FilterChanged(filterEvent);
}
}
Code .NET SQL :: ASP.NET :: C#
Page 1 sur 1
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum