在 Sharepoint 中更新和快速读取列表

发布于 2024-11-10 11:33:18 字数 648 浏览 6 评论 0原文

我有一个具有这种行为的 Web 部件:

  • 加载时,它会读取 Sharepoint 列表,然后显示一条弹出消息。
  • 当我接受消息时,Web 部件会更新列表。

为了读取值,我在 CreateChildControls 中有一个函数

protected override void CreateChildControls() {
readList()
... 
otherStuff
}

,并保存值,我有一个隐藏字段,它在更改值时执行保存函数:

hiddenField.ValueChanged += new System.EventHandler(functionThatSavesTheValue);

然后,当用户接受弹出窗口的消息时,我通过 javascript 更改隐藏字段的值,执行 functionThatSavesTheValue

button.value = '1' + button.value;

从这里开始,一切正常。

问题是如果我在按下按钮后重新加载页面。

在这种情况下,读取列表的函数在保存值的函数之前执行,并且我得到错误的值。我可以做什么来解决这个问题?

I have a webpart with this behaviour:

  • When it loads, it reads a Sharepoint list, and then shows a popup message.
  • When I accept the message, then the Webpart updates the list.

To read the value I have a function inside CreateChildControls

protected override void CreateChildControls() {
readList()
... 
otherStuff
}

and to save the value I have a hiddenField, that executes the save function when changes the value:

hiddenField.ValueChanged += new System.EventHandler(functionThatSavesTheValue);

Then when the user accept the message of the popup, I change the value of the hiddenField via javascript, to execute the functionThatSavesTheValue

button.value = '1' + button.value;

Since here, all works fine.

The problem is if I reload the page just after push the button.

In that case, the function that reads the list executes before the function that saves the value, and I get wrong values. What can I do to fix this?

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

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

发布评论

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

评论(1

默嘫て 2024-11-17 11:33:18

您可以使用 CreateChildControls 初始化控件并读取 OnPreRender 中的列表。

You could use CreateChildControls to initialize your controls and read the list in OnPreRender.

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