Error Saving ASPX Pages with Duplicate Web Part IDs

I was working with an aspx page in SharePoint Designer and wanted to copy a Data View Web Part (DVWP) and use it again on the same page with different parameters.  (Same data source, just different filtering.)  Every time I did so, everything rendered just fine in Designer, but when I went to save the file, I got the following error:

Server error: The URL ‘filename’ 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.

Certainly not much to go on.  After a bit of fiddling, I realized the the problem was that I had introduced a duplicate Web Part ID by simply doing a copy of the code.  The solution was to insert a new DVWP, add a data source and a column to instantiate it, and then replace the inner code (i. e., everything except the first and last lines) with the code from my original Web Part.

Similar Posts

4 Comments

  1. Thanks for posting this, I was just about ready to put my foot through the screen…

  2. For testing purposes, I have made various versions of a page. I finally realized that saving the page was clobbering the DVWPs on the other clones. Is there any magic in the ID and __WebPartID or could I use a generator to create random IDs? This would be quicker than creating DVWPs for each then replacing the content.

    1. DBPopcorn:

      I use the technique you describe all the time to create vNext of my pages with DVWPs and I’ve never seen what you describe. All of the code for the DVWPs lives in each page, so saving one page should have zero impact on another. Or do you actually mean new versions, as in version control? I typically simply makes copies, e.g., default.aspx copied to default2.aspx. I work on default2.aspx until I’m satisfied with my changes, and then I awap the two files by renaming default2.aspx -> default.aspx.

      M.

      1. The pages are saved in the default Site Pages which does have major versioning turned on. I agree that separate pages should not affect each other. It took me a while to realize what was triggering the disapearance of DVWPs on the page. The WP zones just blanked out the entire DVWPs however asp DDL control and external list WP were not broken. I do have more than one page that requires unique IDs for production and testing to prevent pooching. Changing the ID and __WebPartID has resolved this problem.

Leave a Reply to Seth Petry-Johnson Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.