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.


  1. 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.

    • 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.


      • 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.


Have a thought or opinion?