I could probably write an entire book on the strange things that SharePoint Designer does, but I don’t have time for that. Instead, it’s yet another blog post.
Today I was adding some Data View Web Parts (DWVPs) to a page, and I took the shortcut of copying and pasting the code of one to create another in the same page. This always works, but there are some things you have to do to pull it off.
When I went to save the page, I got this rather cryptic error:
Server error: The URL Pages/Employee Handbook.aspx is invalid. It may refer to a nonexistent file or folder, or refer to a valid file or folder that is not in the current Web.
Now, obviously the page existed, as it was the one I was editing, and the path was right, because it was the original location.
After thinking about it for a few minutes, I realized that I had forgotten to change the GUID in the copy of the original DVWP. I had two DVWPs in the same page with the same GUID, which is a no-no. Of course, the error is totally confusing and doesn’t indicate the actual problem.
If you copy and paste a DVWP’s code to create a new one, you have to change [at least] two attributes in either the original or the copy. Both the ID and the __WebPartId must be unique. They will look something like this:
I admit that I always cheat on this and simply change the last character of the two GUIDs. I know I’m supposed to use some GUID generator, but the only place that these two GUID must be unique is within the current page.