By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,292 Members | 1,718 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,292 IT Pros & Developers. It's quick & easy.

complex event bubbling problem

P: n/a
the following event handler checks to see if any parent control has
attached to the event 'SearchItemSelect'. i use it for event bubbling
whenever one of my search items has been selected and at the moment i
am calling this from a repeater's ItemCommand event handler:

protected void OnSearchItemSelect(EventArgs e)
{
if (SearchItemSelect != null)
{
SearchItemSelect (this, e);
}
}

i now want to call this from within a different function, NOT an event
handler. basically if the user's search returns only one hit I don't
want to display a repeater I just want to bubble an event up to the
mother page straight away. i tried this:

OnSearchItemSelect();

but i get the error message "No overload for method
'OnSearchItemSelect' takes '0' arguments. i realise that ive got to
pass it a variable of type 'e'. But what do I pass it as I am not
calling it from within a repeater's event handler anymore but just
from a general method? how can i overload my event?

----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Wes:

You can create the EventArgs instance yourself, i.e:

EventArgs e = new EventArgs();
OnSearchItemSelect(e);

or simply

OnSearchItemSelect(new EventArgs());

Since the EventArgs class does not have information (state) about the
event to pass along, this should work fine. Other event argument
objects contain information about the type of event and who the event
is coming from, but EventArgs is pretty braindead.

HTH,

--
Scott
http://www.OdeToCode.com

On 21 May 2004 10:25:54 -0500,
ma***********@yahoo-dot-com.no-spam.invalid (Wee Bubba) wrote:
the following event handler checks to see if any parent control has
attached to the event 'SearchItemSelect'. i use it for event bubbling
whenever one of my search items has been selected and at the moment i
am calling this from a repeater's ItemCommand event handler:


Nov 18 '05 #2

P: n/a
Does it basically make any difference if you treat it as an ordinary method
call? You could call it:

OnSearchItemSelect(EventArgs.Empty);

but certainly if you work with event bubbling as it really works, the type
of the event argument should be CommandEventArgs (in
System.Web.UI.WebControls) namespace. If it needs that, just instantiate
System.Web.UI.WebControls.CommandEventArgs with proper command event data
and pass it to the method.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke

"Wee Bubba" <ma***********@yahoo-dot-com.no-spam.invalid> wrote in message
news:40********@127.0.0.1...
the following event handler checks to see if any parent control has
attached to the event 'SearchItemSelect'. i use it for event bubbling
whenever one of my search items has been selected and at the moment i
am calling this from a repeater's ItemCommand event handler:

protected void OnSearchItemSelect(EventArgs e)
{
if (SearchItemSelect != null)
{
SearchItemSelect (this, e);
}
}

i now want to call this from within a different function, NOT an event
handler. basically if the user's search returns only one hit I don't
want to display a repeater I just want to bubble an event up to the
mother page straight away. i tried this:

OnSearchItemSelect();

but i get the error message "No overload for method
'OnSearchItemSelect' takes '0' arguments. i realise that ive got to
pass it a variable of type 'e'. But what do I pass it as I am not
calling it from within a repeater's event handler anymore but just
from a general method? how can i overload my event?

----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption

=---
Nov 18 '05 #3

P: n/a
thanks a lot scott. that worked a treat. ive been trying to work that
one out all day!!! nice one matey!!! :D
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 18 '05 #4

P: n/a
also scott, whilst i got ya, i posted another question about dataList
control ID's. i was wondering if you knew the answer to that one
too... :wink:
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.