SharePoint Web 用户控件下拉框值帮助
我有一个页面index.aspx,此页面有两个Web 用户控件,list.ascx 和display.acsx 基本上list.ascx 将该SharePoint 站点上可用的所有列表显示到下拉框中。第二个 Web 用户控件显示所选列表中所有文件的列表。但是我遇到了问题,我的问题是如何将下拉框的值从第一个 Web 用户控件传输到第二个 Web 用户控件。
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
鉴于您正在使用自定义 Web 控件,我发现将两个不同的控件作为依赖项本质上链接在一起是一个坏主意。相反:
在第一个控件上定义一个事件,该事件使用包含数据的事件参数适当引发。
让包含的index.aspx 页面具有此事件的处理程序。
在此处理程序中,在第二个控件上设置适当的属性,传递来自事件参数的数据。
这更干净,实现了您想要的并将两个控件相互解耦。
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:
Define an event on the first control that is raised appropriately with event arguments containing the data.
Have the encompassing index.aspx page have a handler for this event.
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.
当值更改时,您的 list.ascx 需要将 ListId 回发到服务器,
jQuery 可以在这里提供帮助,或者您可以使用 OnSelectedIndexChanged 和 AutoPostBack 在服务器端完成此操作。
然后你的display.acsx,只需要从请求中读取ListId。
Your list.ascx needs to postback the ListId to the server when the value is changed
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.
如果你只是想粗暴地传递一次数据,不附加任何条件:
创建一个类,其中包含要传递的数据类型的静态成员。
在第一个 ascx 文件中设置值并在第二个 ascx 文件中读取。
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..