Selecteditem.value for a listbox in a user control

D

Dave

Greetings,

How can I access the selecteditem.value property for a listbox that is in a
user control (.ascx) inside of my .aspx page? Thanks,

-Dave
 
M

Matt Berther

Hello Dave,

If you need access to it from the page, you can do two things.

1: (Least desirable) Expose the listbox as a public variable from the ASCX
file
2. (Most desirable) Create a public property in your ASCX file and reference
the property from the ASPX

Example:

(in the .ascx)
public object ListBoxValue { get { return myListbox.SelectedItem.Value } }

(in the .aspx)
object o = myAscxControl.ListBoxValue;
 
D

Dave

Matt,

Thanks for the help. I have that part down now, but I must have another
issue (I can't reference the User Control from code, even though it shows up
fine). I posted it as a new post. If you can help me further on that, I
would be greatly appreciative. Thanks,

-Dave
 

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
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top