在 sharepoint 自定义 Web 部件中使用 asp.net 用户控件

发布于 2024-10-10 06:33:58 字数 508 浏览 0 评论 0原文

所以我需要创建一个网络部件。我想要对设计过程进行一些控制,并为控件创建代码,然后构建/编译等待应用程序回收,然后 F5 共享点、冲洗和重复站点是一种痛苦。

我读到可以只创建一个常规用户控件,并将其加载到 Web 部件中。我认为理想 - 但是!

所有共享点的东西怎么样?喜欢属性,以及与共享点列表交互等?我如何通过用户控件最好地实现这一点?

我确切需要的是一个 Web 部件,首先显示共享点列表中一个项目的一组信息,其次它需要显示另一个共享点列表中的项目的可滚动列表。

有没有一种奇特的方法来获得几乎相同的“环境”,或者我应该像这样:

using(SPSite site = new SPSite("http://mysite/")){
    using(SPWeb web = new SPWeb("myWeb")){
         //Fill a listbox with web.lists["myList"];
    }
}

从我的用户控件的代码隐藏中?

So I need to create a webpart. I'd like some control over the design process, and creating the code for the controls then build/compile wait for app-recycle and then F5 the sharepoint, rinse and repeat site is a pain.

I was reading that it's possible to just create a regular user control, and have that load in the webpart. Ideal I think - but!

What about all of the sharepoint stuff? Like the properties, and interacting with sharepoint lists and so on? How would I accomplish this best from the user control?

What I need exactly, is a webpart displaying firstly a set of information of one item in a sharepoint list, and secondly it needs to show a scrollable list of items from another sharepoint list.

Is there a fancy way of getting pretty much the identical 'environment' or should I just go like:

using(SPSite site = new SPSite("http://mysite/")){
    using(SPWeb web = new SPWeb("myWeb")){
         //Fill a listbox with web.lists["myList"];
    }
}

From the code-behind of my usercontrol?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我很OK 2024-10-17 06:33:58

是的,就是这样的写法。

只是您可以编写用户控件,然后将其托管在包装器 Web 部件中,而不是直接编写 Web 部件。

这种方法的优点是您可以让设计器创建 UI 元素,这些元素在创建用户控件时可用。对于 sharepoint 2007,包装器 Web 部件已经可用,称为智能部件。对于 smartpart,您只需提供要加载的用户控件(.ascx)的位置即可。

在 sharepoint 2010 中,可以使用 Visual Studio 2010 开箱即用地构建 smartpart。

http://smartpart.codeplex.com/

Yes, that is the write way.

It's just that instead of writing webpart directly, you can write the usercontrol and then host it in a wrapper webpart.

The advantage of this approach is that you can have designer for creating UI elements which is available while creating usercontrol. For sharepoint 2007, the wrapper webpart is already available called smart part. To smartpart, you can just give the location of your user control(.ascx) to load.

In sharepoint 2010, the smartpart can be built out of the box using Visual Studio 2010.

http://smartpart.codeplex.com/

挖鼻大婶 2024-10-17 06:33:58

您必须创建扩展 WebPart 类的简单 Web 部件。在其中,您可以通过覆盖 CreateChildControls 来添加自己的控件 方法。您可以在控件的构造函数中传递任何必需的参数。至于属性,您可以在包装器 Web 部件中描述它们并将其映射到控件属性。

You have to create simple web part which extends WebPart class. Inside it you may add your own control by overriding CreateChildControls method. You may pass any required arguments in the constructor of your control. As for the properties you may describe them in wrapper web part and map it to control properties.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文