Sharepoint:从编辑表单提交表单数据,然后重定向到显示表单

发布于 2024-08-11 00:10:35 字数 315 浏览 8 评论 0原文

这是用于将数据提交到自定义列表的自定义 Editform.aspx。用户完成表单后,他应该能够点击按钮甚至“确定”按钮,并让 sharepoint 将表单数据提交到列表,然后重定向到项目显示表单 (dispform.aspx?ID='itemid') 。 我能够通过操作 document.location.href 来获取当前项目的 ID。我尝试使用 __doPostBack 和 __commit 和 __redirect (重定向到 URL displayform?ID='itemid')在 javascript 中进行回发,但是当重定向发生时,我发现更改没有更新!

有人能做这样的事情吗?

This is for a custom Editform.aspx being used to submit data to a custom list. Once the user completes the form, he should be able to hit a button or even the OK button, and have sharepoint submit the form data to the list, then redirect to the items Display form (dispform.aspx?ID='itemid').
I was able to get the ID of the current item by manipulating document.location.href. I tried to do a postback in javascript using __doPostBack with __commit and __redirect (redirecting to the URL displayform?ID='itemid'), but when the redirect happens, I see that the changes were not updated!

Anyone able to do something like this?

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

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

发布评论

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

评论(2

蒲公英的约定 2024-08-18 00:10:35

通过修改源查询字符串参数中的 URL,您可以使表单在发布后重定向到任何位置。使用 javascript,您可以在该查询字符串参数中查找特定的 URL (/location/dispform.asp?ID=),如果不存在,则将页面重定向到其自身,但将 Source 参数填写到 w 的位置/ 您要将其发送到的 ID。

最难的部分是在 javascript 中解析当前 URL + 参数。我发现一些 JS 代码片段可以让事情变得更容易。

以这种方式重写 EditForm URL 的好处之一是,Cancel 按钮会将用户发送到 DispForm 页面,而不是他们最初来自的位置,尽管大多数人可能会使用后退按钮。

You can get the form to redirect to any location after it's been posted by modifying the URL in the Source querystring parameter. Using javascript, you could look for a specific URL (/location/dispform.asp?ID=) in that querystring parameter and if it doesn't exist, redirect the page to itself, but with the Source parameter filled out to the location w/ ID that you want to send them to.

The hardest part will be parsing the current URL + parameters in javascript. There's some snippets of JS code I've found that make it a lot easier.

One of the bonuses of rewriting the EditForm URL this way is that the Cancel button will send the user to the DispForm page instead of where they originally came from, although most people probably use the back button.

你又不是我 2024-08-18 00:10:35

这导致我解决了 DispForm 上的表单操作问题,该操作不会将列表项 ID 传递给自定义 EditForm。以下内容最终为我工作:

onclick="javascript: {ddwrt:GenFireServerEvent(concat('__redirect={ProgEditForm.aspx?ID=+',$ListItemId,'}'))}"

其中我有一个 ListItemIDDispForm 参数

参数来源:查询字符串
查询字符串变量:ID
默认值:0

希望对其他人有帮助,因为这几乎让我发疯!

This lead me to solve my problem of a Form Action on my DispForm that would not take the list item ID to the custom EditForm. The following ended up working for me:

onclick="javascript: {ddwrt:GenFireServerEvent(concat('__redirect={ProgEditForm.aspx?ID=+',$ListItemId,'}'))}"

Where I have a DispForm parameter for ListItemID with

Parameter Source: Query String
Query String Variable: ID
Default Value: 0

Hope that helps someone else as this was near driving me crazy!

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