Search code examples
c#asp.netsharepoint-2007webusercontrol

SharePoint Web User Control DropDown Box Value Help


I have a page index.aspx this page has two Web user Controls, list.ascx and display.acsx basically list.ascx shows all the lists that are available on that SharePoint site into a dropdown box. The second web user control, displays a list of all the files in the list selected. But there's where I run into the problem my question is how do I transfer the value of the dropdown box from the first web user control into the second one.

thanks


Solution

  • Given that you are using custom web controls, it's a bad idea I find, to intrinsically link two different controls together as dependents. Instead:

    1. Define an event on the first control that is raised appropriately with event arguments containing the data.

    2. Have the encompassing index.aspx page have a handler for this event.

    3. Within this handler, set an appropriate property on the second control, passing the data from the event argument.

    This is much cleaner, achieves what you want and de-couples the two controls from one another.