R
Ranginald
How could I go about creating a custom event handler for a web controls
method (e.g. OnSelectedIndexChanged) and have that method say,
ItemChanged() -- be called from a separate class (for example,
class1). My goal is to store some event handlers that I will use often
in a separate class so I don't have to retype them every time I need
them .
I. I am having a problem "telling" the web control (a dropdownlist
for example) to "look" in class1 for the ItemChanged() method.
II. No matter what I try (and I've been trying) I can't seem to get
the class to "see" the control on the page.
Sample Code:
=====
default.aspx
- a blank page -- all is being done with code (so I can learn)....
default.aspx.cs
using.....
page_load
{
DropDownList ddlOne = new DropDownList();
this.controls.add(ddlOne);
ddlOne.Item.Add("Sample One")
ddOne.Item.Add("Sample Two")
ddlOne.Item.Add("Sample Three")
ddlOne.SelectedIndexChanged = [[[somehow tell this method to find
the ItemChanged() method of Class1]]
}
class1.cs
pulbic void class1()
{
public void ItemChanged() //does this need to be in the
constructor to be called?
{
doSomething()
}
}
Thanks!
method (e.g. OnSelectedIndexChanged) and have that method say,
ItemChanged() -- be called from a separate class (for example,
class1). My goal is to store some event handlers that I will use often
in a separate class so I don't have to retype them every time I need
them .
I. I am having a problem "telling" the web control (a dropdownlist
for example) to "look" in class1 for the ItemChanged() method.
II. No matter what I try (and I've been trying) I can't seem to get
the class to "see" the control on the page.
Sample Code:
=====
default.aspx
- a blank page -- all is being done with code (so I can learn)....
default.aspx.cs
using.....
page_load
{
DropDownList ddlOne = new DropDownList();
this.controls.add(ddlOne);
ddlOne.Item.Add("Sample One")
ddOne.Item.Add("Sample Two")
ddlOne.Item.Add("Sample Three")
ddlOne.SelectedIndexChanged = [[[somehow tell this method to find
the ItemChanged() method of Class1]]
}
class1.cs
pulbic void class1()
{
public void ItemChanged() //does this need to be in the
constructor to be called?
{
doSomething()
}
}
Thanks!