简体   繁体   English

SharePoint 2007 自定义 Webpart,将数据保存到属性

[英]SharePoint 2007 Custom Webpart, saving data to the properties

How can I go about creating a custom Web Part that has a custom UI for editing.我如何 go 关于创建具有自定义 UI 进行编辑的自定义 Web 部件。 When the page is in Edit mode I have a special button show up "Edit" and when the user clicks on it it posts back to the page.当页面处于编辑模式时,我有一个特殊的按钮显示“编辑”,当用户单击它时,它会发回页面。 I catch this and I want to display a custom UI so they can edit the web part properties.我发现了这一点,我想显示一个自定义 UI,以便他们可以编辑 web 部件属性。 I need to be able to have rich text fields, and text fields that are editable and will post back so I can save them to the properties.我需要能够拥有富文本字段,以及可编辑的文本字段并将回发,以便我可以将它们保存到属性中。

I'm struggling mostly with creating a RichTextField, or TextBox that I can grab the data in post back.我主要在努力创建一个 RichTextField 或 TextBox,我可以在回传中获取数据。 I know how to do it if I outputted raw HTML to the page, then use HTTP.Context, but what's the C# way to do it?如果我将原始 HTML 输出到页面,然后使用 HTTP.Context,我知道该怎么做,但是 C# 方法是什么?

Thanks!谢谢!

You can check in your web part if page is in Edit mode or Display mode and render the controls accordingly.如果页面处于编辑模式或显示模式,您可以检查您的 web 部件并相应地呈现控件。

How to tell if page is in edit mode on a non-publishing site 如何判断页面是否在非发布站点上处于编辑模式

On postback, you can fetch the values and assign it to your web part properties.在回发时,您可以获取这些值并将其分配给您的 web 部件属性。 Since you are handing it custom, you will need to set dirty flag:由于您是自定义处理它,因此您需要设置脏标志:

http://msdn.microsoft.com/en-us/library/ms157656.aspx http://msdn.microsoft.com/en-us/library/ms157656.aspx

It sounds like you're putting a configuration UI into the web part itself?听起来您正在将配置 UI 放入 web 部件本身?

The standard way to provide a configuration UI is via the toolpart - the tall thin window that appears down the right hand side of a page when you edit a web part.提供配置 UI 的标准方法是通过工具部件 - 编辑 web 部件时出现在页面右侧下方的高瘦 window。

These posts should give you a good introduction:-这些帖子应该给你一个很好的介绍:-

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM