Document directory
- What have you modified?
- The screen status at this time
Before we replace the old one with a new one, we 'd better have a backup. This is not a kind of nostalgia, but because it may be damaged. When you need to return to the status before modification, It is very convenient to have the previously saved backup.
What have you modified?
By comparing the data when the page is loaded and the data when the Save button is clicked, we can get the information modified by the user and then do what we want to do accordingly. In the previous article, we learned how to use the asp: label control. Although the label cannot be edited in the form, it can make the form field available in the form operation workflow.
We can add any columns to the form from various data sources. We only need to add a tag to the form in the same way.
In SharePoint Designer (SPD:
1. Switch to edit Template
2. click in the cell (any row) where you want to store the label (make sure that the existing form fields in the cell are not selected; otherwise, the field will be replaced. If you cannot select an existing domain, you can find the highlighted code block corresponding to the domain in the split view and move the cursor to the end mark of the TD code block .)
Click a cell (do not place it on data ). We will add tags at this location
3. Select the columns to be inserted from the "data source details" panel.
4. Click "insert selected domain into..." and select "formatted..."-> "tag"
5. You can see that both the design view and the Code view have changed:
6. Now, we need to hide it and modify it as follows...
From:
<td class="ms-vb"><SharePoint:FormField runat="server" id="ff1{$Pos}" ControlMode="Edit" FieldName="Title" ... /><SharePoint:FieldDescription runat="server" id="ff1description{$Pos}" FieldName="Title" ControlMode="Edit" /><asp:Label runat="server" id="ff4{$Pos}" text="{@_x804c__x4f4d__x7f16__x53f7_}"... /></td>
Changed:
<td class="ms-vb"><SharePoint:FormField runat="server" id="ff1{$Pos}" ControlMode="Edit" FieldName="Title" ... /><SharePoint:FieldDescription runat="server" id="ff1description{$Pos}" FieldName="Title" ControlMode="Edit" /> <span style="display:none"> <asp:Label runat="server" id="ff4{$Pos}" text="{@_x804c__x4f4d__x7f16__x53f7_}" ... /> </span></td>
The screen status at this time
The tag is hidden but still bound to the data source. Therefore, the current data is displayed when the page is loaded. You cannot modify it.
The hidden TAG provides a snapshot of data when the page is loaded.
Repeat the same process for each column that needs to record the status before modification. From the perspective of ease of maintenance, placing each hidden tag in the same cell as the corresponding form field will be helpful for your future positioning. However, since they are hidden, you can also put them together in a span tag.
Next time: Do you always want to know how to use PreSaveAction? As I said before, I will return to this topic. In the subsequent expansion of the DVWP series, we will actually do something useful.
References
SharePoint: Extending the DVWP-Part 12: Adding More Form Fields from the Data