开发者

SharePoint Web User Control DropDown Box Value Help

开发者 https://www.devze.com 2023-02-07 05:02 出处:网络
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. 开发者_

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. 开发者_StackOverflowThe 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


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.


Your list.ascx needs to postback the ListId to the server when the value is changed

<select onchange="PostBackWithListId();" >
 <option value="SomeListId">
</select>

jQuery could help here, or you could do it server side with OnSelectedIndexChanged and AutoPostBack.

Then your display.acsx, just needs to read the ListId from the request.


If you just want to pass the data once brutally, no strings attached: make a class with a static member of the type of data you want to pass. set the value in one ascx file and read in the second ascx file..

0

精彩评论

暂无评论...
验证码 换一张
取 消