L
Luis Esteban Valencia Muñoz
Hello Experts,
I have three classes: Globals.cs, FunctionalArea.ascx.cs, and
ReprotList.ascx.cs.
The idea is that when one drop down is changed (i.e. Functional Area),
another drop down on the page (Reports) would get updated. Both of theses
are controls in the same web form.
In Globals.cs:
----------------------------------------------------------------
public delegate void FunctionalAreaChangedHandler(object sender,
FunctionalAreaEventArgs args);
public class FunctionalAreaEventArgs : EventArgs
{
private string _functionalArea = string.Empty;
public FunctionalAreaEventArgs(string functionalArea)
{
_functionalArea = functionalArea;
}
public string getFunctionalArea
{
get { return _functionalArea; }
}
}
In FunctionalArea.ascx.cs:
----------------------------------------------------------------
public event Globals.FunctionalAreaChangedHandler FunctionalAreaChanged;
// When the user changes the Funcational Area drop down, run
OnFunctionalAreaChanged.
private void dropFunctions_SelectedIndexChanged(object sender,
System.EventArgs e)
{
OnFunctionalAreaChanged();
}
protected void OnFunctionalAreaChanged()
{
if(FunctionalAreaChanged != null)
{
FunctionalAreaChanged(this, new
Globals.FunctionalAreaEventArgs(dropFunctions.SelectedValue));
}
}
In ReprotList.ascx.cs:
----------------------------------------------------------------
private FunctArea _functArea = new FunctArea();
private void OnFunctionChanged(object sender,
Globals.FunctionalAreaEventArgs args)
{
Response.Write("Delegate worked!");
Response.Write("<script>alert('Delegate Worked!');</script>");
}
private void InitializeComponent()
{
...
this._functArea.FunctionalAreaChanged += new
Globals.FunctionalAreaChangedHandler(this.OnFunctionChanged);
}
Unfortunately, the event does not seem to be firing since
"if(FunctionalAreaChanged != null)" always returns false in
FunctionalArea.ascx.cs (i.e. FunctionalAreaChanged == null).
Where is "FunctionalAreaChanged" supposed to be assigned a value? What am I
missing?
Thanks for your help!
I have three classes: Globals.cs, FunctionalArea.ascx.cs, and
ReprotList.ascx.cs.
The idea is that when one drop down is changed (i.e. Functional Area),
another drop down on the page (Reports) would get updated. Both of theses
are controls in the same web form.
In Globals.cs:
----------------------------------------------------------------
public delegate void FunctionalAreaChangedHandler(object sender,
FunctionalAreaEventArgs args);
public class FunctionalAreaEventArgs : EventArgs
{
private string _functionalArea = string.Empty;
public FunctionalAreaEventArgs(string functionalArea)
{
_functionalArea = functionalArea;
}
public string getFunctionalArea
{
get { return _functionalArea; }
}
}
In FunctionalArea.ascx.cs:
----------------------------------------------------------------
public event Globals.FunctionalAreaChangedHandler FunctionalAreaChanged;
// When the user changes the Funcational Area drop down, run
OnFunctionalAreaChanged.
private void dropFunctions_SelectedIndexChanged(object sender,
System.EventArgs e)
{
OnFunctionalAreaChanged();
}
protected void OnFunctionalAreaChanged()
{
if(FunctionalAreaChanged != null)
{
FunctionalAreaChanged(this, new
Globals.FunctionalAreaEventArgs(dropFunctions.SelectedValue));
}
}
In ReprotList.ascx.cs:
----------------------------------------------------------------
private FunctArea _functArea = new FunctArea();
private void OnFunctionChanged(object sender,
Globals.FunctionalAreaEventArgs args)
{
Response.Write("Delegate worked!");
Response.Write("<script>alert('Delegate Worked!');</script>");
}
private void InitializeComponent()
{
...
this._functArea.FunctionalAreaChanged += new
Globals.FunctionalAreaChangedHandler(this.OnFunctionChanged);
}
Unfortunately, the event does not seem to be firing since
"if(FunctionalAreaChanged != null)" always returns false in
FunctionalArea.ascx.cs (i.e. FunctionalAreaChanged == null).
Where is "FunctionalAreaChanged" supposed to be assigned a value? What am I
missing?
Thanks for your help!