在 Sharepoint 中更新和快速读取列表
我有一个具有这种行为的 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 CreateChildControls 初始化控件并读取 OnPreRender 中的列表。
You could use CreateChildControls to initialize your controls and read the list in OnPreRender.