Subscribing to an event

N

nate heaton

I am using Visual C# to develope an ASP.net web application.

In my code behind page I have an event:

this.DropDownList2.SelectedIndexChanged

which fires when the DropDownListChanges.

Now, what I would like to do is fire that event from the

page load event.

I know that there are better ways to do what I want to do.

However, I need to understand this. Please explain how to raise the

SelectedIndexChanged event from the page load event.

Thank you in advance.

Nate Heaton
 
M

Manohar Kamath

The only way I can think of is to change the selected index of your
drop-down list. Since it is an event, you can not call it from outside the
object like you would call a method.

E.g.

myObj.MyMethod (myParm1, myParm2);

An event belongs to the object, and it should raise it internally.

One way I can think of doing this is -- derive from the drop-downlist
another class. In this class, suscbribe to the Page_load event. And within
the event handler, raise the SelectedIndexChanged event.

Is there a simpler way, anyone?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,315
Messages
2,571,636
Members
48,458
Latest member
WernerAble

Latest Threads

Top