Sharepoint and the Invalid page URL error

I am working on a custom list for Sharepoint WSS.  This involves creating a custom master which applies only to the new entry form for the list.  This by itself has its own issues.  You might think you can simply just change the name of your master from “default.master” to “custom.master” wouldn’t you?  Well partner, that is where you would be wrong.  Looking for a quick fix I just used a relative path as noted at the link.   So I ended up with something like:

MasterPageFile="../../_catalogs/masterpage/custom.master

This leads me to where I started having a problem. I am running Vista in a virtual machine via VMWare Fusion and I have Unity enabled.  As I was tabbing back and forth somehow some of the code in my newform.aspx page got deleted.  I didn’t catch it till it was saved and I had reloaded the browser.  This is when I was presented with a white screen with nothing on it, no error, no nothing.  Weird… Sharepoint is usually pretty good about bitching about errors.

So I tried to undo any changes to the file and resave.  Well naturally Sharepoint Designer didn’t have any undo states (does this feature ever work properly in SPD?!).  I reset the file to the site definition so I could get back on my merry way.

I try to add a new item to the list so I could confirm the file was working again.  But wait, what is this?  Invalid page URL??!  WTF?

Yes folks, that’s right.  Even if you replace the code that was accidentally removed the list has been completely hosed.  You are screwed…. yes Microsoft has some official word on it and it isn’t pretty.  If you have the misfortune of accidentally deleting the List Form Web Part from your NewItem.aspx page it is time to hit the big shiny red button and nuke that sucker from orbit.

Just remember Microsoft’s handy advice:

To resolve this issue, delete the list, and then re-create it. Then, customize the NewForm.aspx page. When you customize the NewForm.aspx page, make sure that you do not delete the List Form Web Part.

This roughly translates into “Our product suffers from a catastrophic failure if you remove some code temporarily from a web page”.

3 comments

  1. Your advice on recovering the List View Web part is incorrect. It can in fact be recovered. You are NOT hosed (as you say). It seems the microsoft advice (while functional) is not handy.

    Here is how to fix the issue:

    Problem: You have deleted the List View Web Part from NewForm.aspx because you were customizing it. You then find out that pressing the NEW button on your list causes the invalid url. You may also find that trying to edit existing records throws an object reference error

    Solution:

    Open NewForm.aspx and EditForm.aspx in designer.

    Copy the ListViewWebPart from EditForm into NewForm

    Generate a GUID using a GUID generator.
    If you have the Microsoft SDK installed on your system, you can use the utility uuidgen.exe, which is located in the “C:\Program Files\Microsoft SDK\Bin” directory.

    Now you need to edit the ListFormWebPart you just copied into NewForm.aspx.
    Edit the __WebPartID field and replace it with the GUID you just generated.
    Example:
    __WebPartId=”{14959BD7-F994-40D3-B8A8-0A1AE857EF31}”

    Finally edit the ID tag of your web part. All you need to do here is replace 1 character in the ID tag.
    Example:
    g_9c233833_7d83_4d36_9745_07227e3b396a may get changed to
    g_9c233833_7d83_4d36_9745_07227e3b397a. (I changed the last number from 6 to 7)

    That should do it and your form should be recovered at this point.

    Hope this helps expand your understanding of Sharepoint !

    James

Leave a comment