Home All Groups Group Topic Archive Search About

How do I return the name (ID) of a user control?

Author
13 Sep 2006 2:09 PM
Gummy
Hello,

I have a single user control (contains two listboxes, labels and radio
buttons) that appears on my webpage multiple times. When the radio buttons
are clicked I am able to process (consume?) that Event (SelectedIndexChange)
on
the main page.

What I am having a problem with is figuring out which of the user controls
raised that Event. If I know which user control raised the Event.

How do I tell which user control's radio buttons I clicked?


I have this pseudo-code on the main page:
private void WebForm1_SelectedIndexChange(object sender, EventArgs e)
   {
      DoFunction(  User Control Name);
   }

I tried  sender.GetType().ToString() but that just told me the user control
(UserControl.ascx) and not the actual ID that I assigned to it.

Any help would be greatly appreciated.

Thank you.



p.s. I saw something about a nested Class in the user control that contains
the ID or other information about it, but I certainly don't understand that.

Author
14 Sep 2006 3:03 AM
Gaurav Vaish (www.EduJiniOnline.com)
> What I am having a problem with is figuring out which of the user controls
> raised that Event. If I know which user control raised the Event.
>
> How do I tell which user control's radio buttons I clicked?

Publish an event in the UserContorl - say SelectedIndexChanged.
Raise this event when RadioButton is clicked.

Using the 'sender' semantics and/or appropriate EventArgs, you can send the
'ID' of the UserControl.


Author
14 Sep 2006 2:33 PM
Gummy
Thank you for the information.

I have multiple user controls that I placed in the ASPX page. If I define an
event for each button, droplistbox, etc. in the ASCX, do I need to "wire"
each event, for each user control in the ASPX page?

Thank you.
"Gaurav Vaish (www.EduJiniOnline.com)"
<gaurav.vaish.nospam@nospam.gmail.com> wrote in message
Show quoteHide quote
news:O8UV$p61GHA.4476@TK2MSFTNGP02.phx.gbl...
> > What I am having a problem with is figuring out which of the user
controls
> > raised that Event. If I know which user control raised the Event.
> >
> > How do I tell which user control's radio buttons I clicked?
>
> Publish an event in the UserContorl - say SelectedIndexChanged.
> Raise this event when RadioButton is clicked.
>
> Using the 'sender' semantics and/or appropriate EventArgs, you can send
the
> 'ID' of the UserControl.
>
>
> --
> Happy Hacking,
> Gaurav Vaish | http://www.mastergaurav.com
> http://www.edujinionline.com
> http://articles.edujinionline.com/webservices
> -------------------
>
>
Author
15 Sep 2006 1:30 AM
Gaurav Vaish (www.EduJiniOnline.com)
> Thank you for the information.
>
> I have multiple user controls that I placed in the ASPX page. If I define
> an
> event for each button, droplistbox, etc. in the ASCX, do I need to "wire"
> each event, for each user control in the ASPX page?

Yes.
Because, for each of the buttons in 'myself', you want to tell that 'I' have
been clicked.


Author
15 Sep 2006 2:12 AM
Gummy
Thank you!


"Gaurav Vaish (www.EduJiniOnline.com)"
<gaurav.vaish.nospam@nospam.gmail.com> wrote in message
Show quoteHide quote
news:OIy$VaG2GHA.4588@TK2MSFTNGP04.phx.gbl...
>> Thank you for the information.
>>
>> I have multiple user controls that I placed in the ASPX page. If I define
>> an
>> event for each button, droplistbox, etc. in the ASCX, do I need to "wire"
>> each event, for each user control in the ASPX page?
>
> Yes.
> Because, for each of the buttons in 'myself', you want to tell that 'I'
> have been clicked.
>
>
> --
> Happy Hacking,
> Gaurav Vaish | http://www.mastergaurav.com
> http://www.edujinionline.com
> http://articles.edujinionline.com/webservices
> -------------------
>
>