12

I was asked to add a list view web part to an application page.

I added a web part zone into the page markup. I got a security error when I tried to add it so I added a form digest control (not sure if that was correct, but it changed the error). The next errors were about the list being hidden, and after searching I found that it's because of the view having a BaseIndexID(?) of 1 (which needs to be 0), and that value is read only programmatically.

I'd like to avoid having to add any more files to the VS project. The lists were created through the site, meaning I don't have list definitions in the project.

I've had it with this today so I hoping someone can give me guidance/put me on the right track. This is for MOSS2007 and publishing is disabled.

1
  • <br> is it possible to add to an Application Page the webpart I do not have source code for? <br>I cannot include it into the VS project, it is only deployed on the SharePoint (it is 3rd party webpart).<br> Thanks, Radek
    – Radek
    Feb 15, 2015 at 21:31

2 Answers 2

7

Placing webparts to application pages (i.e. within _layouts folder) actually is not a very good idea, especially when it comes to OOTB SharePoint webparts. Personally, I'd prefer to avoid this, because although it's possible, but AFAIK it is not officially supported by Microsoft and there are some known issues, for example I can recall the XsltListViewWebPart bug with XLST files caching, etc.

Thus I'd recommend you to consider using ListViewByQuery control instead of list view webparts.

ListViewByQuery Class

Renders a list view within a Web Part or ASPX page according to a specified query.

14

You can use webparts on your application page. They won't be customizable then, but they are put on the page as webcontrols:

register your namespace that your webpart resides in:

<%@ Register TagPrefix="prefix" Namespace="YourNameSpace" Assembly="Assembly" %>

Then add your webcontrol by using the following code:

<prefix:WebPartClassName ID="ID" FrameType="None" runat="server" __WebPartId="webpartGuid" WebPart="true" />

success on it!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.