Programmatically modify Library/List Page

Hi,
is it possible to modify a List or Library Page programatically:
1. Add a webpart
2. Change the layout (2 column)
If adding a webpart is possible then do i have to add it to all viewpages or only to the default page?
I want to add a webpart to the library page in best case with a 2 column layout.
Best Regards
Bog
Developers Field Notes | www.bog1.de

hi dear yavuz
bellow is complete code for your needs
PublishingPage newPage = ProvisionPage(web, "Blank Web Part Page", "Home", "Page Description", "Default.aspx");
SPFile pageFile = newPage.ListItem.File;
ContentByQueryWebPart cqwp = new ContentByQueryWebPart(string.Empty, string.Empty, "");
cqwp.Title = "cqwp";
SPLimitedWebPartManager wpm = web.Web.GetLimitedWebPartManager(pageFile.Url, System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
wpm.AddWebPart(cqwp, "Top", 0);
wpm.SaveChanges(cqwp);
if (pageFile.CheckOutType != SPFile.SPCheckOutType.None)
pageFile.CheckIn("Checked by system.");
pageFile.Publish("Published by system.");
public static PublishingPage ProvisionPage(PublishingWeb publishingWeb, string pageLayoutName, string pageTitle, string pageDescription, string pageFileName)
PageLayout[] layouts = publishingWeb.GetAvailablePageLayouts();
Dictionary<string, PageLayout> pageLayouts = new Dictionary<string, PageLayout>();
foreach (PageLayout item in layouts)
string cID = item.Title.ToString();
string name = item.Name;
if (!pageLayouts.ContainsKey(cID.ToUpper()))
pageLayouts.Add(cID.ToUpper(), item);
PageLayout layout = pageLayouts[pageLayoutName.ToUpper()];
PublishingPage newPage2 = null;
SPListItem prevpage = PageExists(publishingWeb, pageFileName);
if (prevpage!=null)
prevpage.Delete();
newPage2 = publishingWeb.GetPublishingPages().Add(pageFileName, layout);
newPage2.Description = pageDescription;
newPage2.Title = pageTitle;
newPage2.Update();
return newPage2;
public static SPListItem PageExists(PublishingWeb publishingWeb, string pageFileName)
bool pageExists = false;
SPList pageList = publishingWeb.PagesList;
foreach (SPListItem li in pageList.Items)
if (li.Name.ToLower() == pageFileName.ToLower())
pageExists = true;
return li;
return null;
yaşamak bir eylemdir

Similar Messages

  • How to Filter list/library view pages from Search Results?

    Hi All,
    Currently my search configuration is searching everything on a site collection. I have created custom scope for that.
    But I would like to remove the search results for list/library views. The search should only show the documents, pages (but not list/library view pages).
    Please guide me on this.
    Appreciate your help.
    Thanks,
    Rahul Babar
    ASP.NET, C# 4.0, Sharepoint 2007/2010, Infopath 2007/2010 Developer http://sharepoint247.wordpress.com/

    Navigate to the site that contains the list or library that you want to change.
    Locate and click the list or library you want to customize.
    Click Site Actions, and then click Site Settings.
    Under Site Administration, click Site Libraries and lists.
    Click an item from the list, for example, Customize “Shared Documents.”
    On the List Settings page, under General Settings, click
    Advanced settings.
    In the Search section, under Allow items from this document library to appear in search results, select
    Yes to include all of the items in the list or library in search result or
    No to exclude all items from search results.
    http://office.microsoft.com/en-in/office365-sharepoint-online-enterprise-help/enable-content-to-be-searchable-HA010379092.aspx

  • Add JavaScript file to ALL existing Task List pages and to newly created list pages

    We have several OOTB task lists that are in use on several subsites.  We want to add JavaScript to the NewForm.aspx and EditForm.aspx for these task lists. These lists have not been customized, they are based on the standard Task Content Type.
    Since there are several lists already created and in use, it would be far too much work to manually add a Content Editor web part to each page.
    We put the JavaScript file in the top-level site style library.
    Is there a way to programmatically attach a script reference to each existing page in all the subsites AND have the script reference placed on any NEW list pages created from the OOTB Task content type? Or, add a CEWP to all existing list pages using a feature?
    I could not find any examples of this.

    Hi,
    A solution would be like this: Add your script into a Content Editor Web Part in a page, then add this Content Editor Web Part into the NewForm page of these Task lists using
    SharePoint Object Model.
    More information:
    Use
    SPList.Forms property to retrieve the URLs of the specific form of these Task lists:
    http://sharepointcore.blogspot.com/2011/08/sharepoint-listitem-new-edit-and.html
    With
    SPLimitedWebPartManager object, we can retrieve the web parts of a page, choose one and add into another
    page:
    SPLimitedWebPartManager.WebParts
    property
    SPLimitedWebPartManager.AddWebPart
    Another two links about this for your reference:
    http://www.stefangordon.com/add-web-part-to-page-programmatically/
    http://sharepoint.stackexchange.com/questions/9442/how-to-programmatically-add-a-webpart-to-a-page
    Thanks
    Patrick Liang
    Forum Support
    Please remember to mark the replies as answers if they
    help and unmark them if they provide no help. If you have feedback for TechNet
    Subscriber Support, contact [email protected]
    Patrick Liang
    TechNet Community Support

  • ? best book for understanding & modifying "Web Part Page" constructs and syntax i.e. WebPartPages:XsltListViewWebPart

    Hello can anyone recommend an in depth "hands on" book or paper for understanding & modifying "Web Part Page" constructs and syntax elements i.e. <WebPartPages:XsltListViewWebPart
    <WebPartPages:XsltListViewWebPart runat="server" AllowHide="True" PartImageSmall="" PartOrder="4" Title="Time" ManualRefresh="False" ViewGuid="{7C672E08-B5D5-435D-A8FE-AB84E97099B1}" 
    So far i've bought every Sharepoint Developer 2007/2010 book available, but none seem to really cover the layout and structure of the XSL methods in enough detail!
    Thanks for any recommendations, links or white paper references ect!

    Hi,
    XsltListViewWebPart is a class that handles view rendering for default lists, such as document libraries and announcements, and it is inherited from Microsoft.SharePoint.WebPartPages namespace.
    Please check the link below for understanding the elements used in the XsltListViewWebPart class:
    http://msdn.microsoft.com/en-US/library/microsoft.sharepoint.webpartpages.xsltlistviewwebpart_members
    More references about XsltListViewWebPart in SharePoint:
    http://msdn.microsoft.com/en-us/library/office/ff604021(v=office.14).aspx
    http://msdn.microsoft.com/library/microsoft.sharepoint.webpartpages.xsltlistviewwebpart
    Best regards.
    Thanks
    Victoria Xia
    TechNet Community Support

  • Aperture 3.5 projects: Some are missing from Library listing

    I use Aperture 3.5.1 with OS 10.9.2, and I have studied the various pages of Aperture manuals, and read quite a few Questions, and I think I understand the difference between projects and albums and between managed and referenced files. But I am puzzled about a few project locations.
    To the left of the Aperture display window is a vertical pane about 2 inches wide, with tabs labeled "Library, Info, Adjustments."
    In that left-hand pane of the window, under the tab “Library” is a heading “APERETURE LIBRARY-MASTER”  and under that is the icon of “Projects”. When I select this, the right hand portion of the full window shows thumbnails representing of all my projects. These are organized by year and for each year, by date. This is the organization that Aperture did when I imported the photos, mostly from cameras. Fine.
    In that left hand pan, under  the Library tab, further down, there is a heading “PROJECTS”. It shows a list of folders and albums and projects.
    I see that in this library there are folders marked 2011 and 2012. In each of those there are folders for the months. In 2012 these include   “May”, “Jun UK", "Jun US", “Jul" and others. When I select any of these the associated thumbnails are all visible in the main display window to the right.
    In the 2012 > Jun UK folder are 5 projects, with dated names such as "Jun 06, 2012 Chicheley". The word “Chicheley” and “UK" I added, but the rest of the structure 2012 > Jun was created by Aperture when I imported the photos.
    However, and here is what puzzles me. In the thumbnail display to the right, of several hundred projects, there are 15 contiguous projects, all from June 2012,  that are not listed in the library panel  of projects in the Library tab pane at the left.
    I can look at the “info” tab and see what the “Project Path” is for any photo. To judge by the badges, All of my photos are managed, not referenced.  Indeed, I cannot find any photos in my Aperture library that are referenced.
    The projects that show up in the Library listing at the left pane have Project paths that start with a year, for example
    2012 > Jun UK > Jun 06, 2012
    The projects that do not show up in the Library listing have names such as
    Jun UK Chicheley > Jun 05, 2012 Aston
    At the top of the Library pane is a search box. It finds Jun 06 but not Jun 05.
    I have looked inside the Aperture Library package and I see the organization there for the projects that show up in the library listing. But that is missing the days that are not in the listing — it is missing the projects that show up in the main window but not in the Library list..
    Those thumbnailed of the missing projects are of photos that are not referenced, I have used the main menu at the top of the screen to check that.
    I can edit all the photos, wherever they may be. No problem. But why do all the projects not show up in the library listing?  Where are they?
    I have used EasyFind to search for a folder “Jun UK Chicheley”, allowing search in packages, but did not find it. Same problem with any of the other 15 projects that show up in PROJECTS  on the right, but not in the Library listing on the left.
    I may have  imported the missing projects not from the camera but from a travel Aperture library, using the import library option.
    Maybe I should select all of these photos and then do a “Consolidate”. I have read about this, in the Manual and in the Suppport questions,  but it is not clear whether that will do what I want. I see that Consolidate is something I can do for any of my photos, not just for those that are not shown in the library. So what happens with Consolidate of a photo that is already in the listing of projects? Should I choose “copy” or “move”? If I choose “move” then what happens to whatever collection these came from?
    “Show in Project” and “Show in Finder” seem to be unavailable for all of my photos.
    I will appreciate help.

    What you're seeing when you try to view the original file is the warning that iPhoto had broken the file path/link to the orignal file.  Try this: make a temporary, backup copy of your library if you don't already have one (Control-click on the library and select Duplicate from the contextual menu) and  apply the two fixes below in order as needed:
    Fix #1
    Launch iPhoto with the Command+Option keys held down and rebuild the library.
    Since only one option can be run at a time start with Option #1, followed by #3 and then #4 as needed.
    Fix #2
    Using iPhoto Library Manager  to Rebuild Your iPhoto Library
    Download iPhoto Library Manager and launch.
    Click on the Add Library button, navigate to your Home/Pictures folder and select your iPhoto Library folder.
    Now that the library is listed in the left hand pane of iPLM, click on your library and go to the File ➙ Rebuild Library menu option
    In the next  window name the new library and select the location you want it to be placed.
    Click on the Create button.
    Note: This creates a new library based on the LIbraryData.xml file in the library and will recover Events, Albums, keywords, titles and comments but not books, calendars or slideshows. The original library will be left untouched for further attempts at fixing the problem or in case the rebuilt library is not satisfactory.
    OT

  • ML upgrade went smooth but I can't access icloud document library from pages or any other app?

    The upgrade went OK but I can't access the icloud document library as described in the Apple features section.  I can't get the dialog option in either Pages or Numbers Open boxes and it is not an option in Finder either.

    1. Switch to Finder bt clicking on your desktop
    2. On the Menu bar is the Go menu
    3. Click on it holding down the option key and you should see the system library listed (exact wording escapes me I am not in Lion)
    Peter

  • Sharepoint Error Message "Configuring column based defaults is only allowed in document library lists"

    We set up a SP 2010 site with several document libraries. Library A works fine only when I click on column default value settings I get the following error message:
    "configuring column based defaults is only allowed in document library lists"
    This list is a normal document library and all other settings work fine. If I create a new document library or go to the settings of document library B I don't see this problem and the feature works fine.
    How can I solve this problem within this library since I cannot delete the library and replace it by a new one.
    Thanks.
    library settings page of this library:

    Hi,
    According to your post, my understanding is that
    when you clicked on column default value settings you got the error message.
    What are the column types in the library?
    It seems that some column types don't support default value settings.
    I recommend to create a new library with the same columns to check whether you can set
    default values.
    If so and the error message persists, please check the SharePoint ULS log to find more information about this error, the ULS log file is in the location: C:\Program Files\Common Files\Microsoft
    Shared\Web Server Extensions\14\LOGS
    You can check the ULS log by the methods here:
    http://blogs.msdn.com/b/opal/archive/2009/12/22/uls-viewer-for-sharepoint-2010-troubleshooting.aspx
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • How can I modify the logon page

    Hi
    Can I modify the logon page of isqlplus.
    Thanks
    Santhosh

    Although in iSQL*Plus 9.0.1 you can't modify the default
    login HTML, you can create your own static HTML "login"
    page. Just make sure the correct login credential
    parameters are passed to the iSQL*Plus URL. Your users will
    have to call your new static page instead of the default
    iSQL*Plus login page.
    Copy the HTML from the default login page and change the
    FORM ACTION to include the host and port:
    <FORM ACTION="http://host.port/isqlplus" METHOD="post">
    and change the "Connection Identifier" field to a drop down
    list of the connection identifiers you want:
    <TD CLASS="label">Connection Identifier:</TD>
    <TD>
    <SELECT NAME="sid">
    <OPTION SELECTED>SID1</OPTION>
    <OPTION>SID2</OPTION>
    <OPTION>SID3</OPTION>
    </SELECT>
    </TD>
    Add your own logo, joke of the day, and put it in
    production....
    iSQL*Plus 9iR2 has an option for a drop down list of connect
    identifiers to be configured in the default login screen.
    This allows sys admins to restrict the DB servers that can
    be accessed. No other connect identifiers can be used, even
    from CONNECT commands in scripts.
    On the OTN home page there seems to be an "early access"
    link for down loading the 9i Database R2.
    -- CJ

  • "Music" library listed under my ipod now?

    I just bought a separate ipod for the gym and when I plugged it in I suddenly had another "Music" library listed directly under my Ipod icon. I even (somehow) created a playlist underneath that but when I went into the tab to click "Sync" music it erased all of what I had just built.
    I've never seen this before. Is it a new feature? If so, what is it's purpose and is there any documentation on this new setup?
    Thanks!
    MACBOOK PRO   Mac OS X (10.4.10)  

    Hi aubiem,
    Welcome to discussions. The "music" library that shows up when you dock an iPod is simply a way to see what is on it while connected. This can be useful if you have a music collection larger than the capacity of your iPod as it provides one convienient place to review everything you have decided to add. Keep in mind that this is not editable directly. Changes must be made by selecting the tabs at the top of your iPods main page. You can elect to add your playlists by clicking on the "music" tab.
    15" PowerBook 1.67 GHz and 12" Powerbook 1.33 GHz   Mac OS X (10.4.9)   60GB iPod 5G

  • InfoView Document List page customization

    I am trying to filter out some of the objects displayed in InfoView Document List page based on the si_name.
    Can some one point me to the java or jar file, which has the query to get the Document list. I can add my filter to the end of the existing query.
    I am working on BOXI 3.1 SP2 with Java SDK. Page which is listing the Document List in infoview is InfoViewListing.jsp.
    Thanks
    Kris

    Modifying Infoview it is not supported so there is no documentation on any of its internal working, layout,  or code structure.
    You will have to figure that out on your own.
    The biggest roadblock you are facing is the huge changes made with Infoview in XI 3.x as opposed to XI R2.  Many things that were easily modifiable in R2 are much much harder 3.x.
    Just an FYI: Note that if you do make any changes and Infoview quits working for any reason you will need to go back to the shipped version in order to be supported.

  • Edit Page options in ribbon disabled after applying modified Seattle Master Page

    Hi,
    I'm working on a modified version of the Seattle.master page, and I have an odd permissions issue that is seen when my user (a farm admin) tries to edit a page on the site. On some pages, clicking Edit Page doesn't do anything at all. On others, I've been
    able to go into edit mode but not do anything with the Edit options afterward. In this scenario, most or all of the useful edit options are disabled, and I cannot use Save, Checkout, Discard the Checkout, Change the Page Layout, etc...
    Checking the JavaScript console in IE reveals this JS error that I don't see in the OOTB Seattle:
    SCRIPT5007: Unable to set value of the property 'href': object is null or undefined 
    [our.site.com], line 1128 character 590
    Here's the function being referenced:
    function _cUpdconetidProjectPropertyTitleGraphic(data, ctrl){ ctrl.href = slNavUrl; }
    Other possibly helpful information:
    Here is a snippet from the modified Seattle Master Page of where the ribbon code sits:
    <div id="s4-workspace" class="ms-core-overlay">
    <div id="s4-bodyContainer">
    <SharePoint:SPSecurityTrimmedControl runat="server" AuthenticationRestrictions="AnonymousUsersOnly">
    <wssucw:Welcome runat="server" EnableViewState="false" />
    </SharePoint:SPSecurityTrimmedControl>
    <div id="ms-designer-ribbon">
    <PublishingRibbon:PublishingRibbon runat="server"/>
    </div>
    As you can see, I have moved the Ribbon (div#ms-designer-ribbon) from its fixed position outside of the div#s4-workspace to inside of the div#s4-bodyContainer so that it scrolls with the page. Placing the ribbon inside div#s4-bodyContainer shouldn't be an issue,
    as I've made a Design Manager Master Page in the past and placed the ribbon there as well without issue.
    Does anyone know how I can get this modified Seattle master page to allow editing?

    Hi,
    Is there any custom JavaScript in it, sometimes error may occur due to some typo.
    Suppose that we can do the customization like this: With a copied master page, we can apply a part of the change first, then check it in the browser to make sure it can work without affecting the OOTB features. Then apply other parts one by one with immediate
    examinations...
    By doing this, it would be easier to find out which step in your whole customization would cause the issue.
    Best regards
    Patrick Liang
    TechNet Community Support

  • I have lots of audiobooks in my library. The problem is each individual cd is listed, it makes my library list very long and when one cd is over I have to click to the next. I would like it to be one big file in order.

    I use my Itunes for all my audiobooks. Right now I may have a book that has 28 Cd's. having many books with many cds in the library makes the library list long and ugly. I would like to consolidate the 28 cd files into one large one. but not screw up the indiviual chapters on each cd. I know Left Click, get into I can orginize more information, under options I have labled them audiobook, but that dose not seem to murge all the cds into one. any ideas?

    Hi Terence:
    so that sounds like better news...I should be OK when this happens?
    Essentially my events become albums...I still have the separation ..correct?
    Why would this be a problem?
    This was a response from an earlier post from Vanoord that concerned me: quote..see next-
    Events has been removed from Photos - it's replaced by 'Moments'.
    'Moments' are like 'Events', but split up by the software and you have no control over what goes where, or what they're called. If you've got 300 Events now, you can look forward to about 3,000 'Moments'.
    This response implies that all my 300 events will become separated into thousands of moments.  What does this mean?  Is this true?
    Won't my Events just become albums as you suggested?
    I have years of events that have accumulated and collated photos.  They must stay separated.
    ****the other thing I was unclear about was the synching part..
    Example:
    I have 300 albums with 30K photos distributed in various numbers in each album ( used to be events according to your response)
    I add some photos in each album each day
    I set all my devices to the cloud etc...
    the cloud synchs from my designated "source" Macbook...
    the cloud sees this and uploads
    then the confusing part...the other devices ( MacBooks, I pad, i phone) all will see the synch and can then be designated to download to each device in the original form as we view it on a Macbook or i phone?  What does "full resolution" or optimized previews mean as Leonie replied above?
    I need my JPEG images for my education keynote presentations and e mailing images as required from each event as needed ( soon to be albums)
    Thanks again...just want to understand what is going to happen

  • How do I programmatically reference the current page in 902?

    Hello,
    How do I programmatically reference the current page in 902?
    The Portal Smart Text option for Current Page is not flexible enough, and I wish to create my own custom greeting using PL/SQL.
    Cheers,
    John

    hi,
    If you are developing a PLSQL Portlet, then you do have a way for getting the page URL.
    The page URL can be obtained from the record, portlet_runtime_record. There is a filed page_urlavailable with portlet_runtime_record.
    The portlet_runtime_record is passed as a argument to the show_portlet procedure.
    --Sriram                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • ITunes -many of my iTunes library list is gone

    after iTunes Crash ( during  iPhone sync terrible sync issue)
    after i re-started iTunes
    in iTunes screen on the left side  many of my iTunes library list is gone.
    and only a few list left.   most of  list is gone missing..
    where can i recover my  full library list?
    is it possible?  is there solution ? step by step someone help me?

    See Empty/corrupt iTunes library after upgrade/crash.
    tt2

  • SharePoint 2013 error while opening listing page

    Dear All,
    I have upgraded my SharePoint 2007 to SharePoint 2010 and SharePoint 2013.
    Currently I m facing problem whenever I click on any list pages (eg. Press Release) on Sharepoint 2010 and 2013 application.
    Attaching the error message. Please help.

    Is there any custom code used in the master page or other pages?
    I'd suggest you open the PR_listing.aspx page in SharePoint designer and then do a search for "ServerContext" and if you get a match, then you or a developer will need to update the code to use the SPServiceContext approach instead.
    If you don't get a match on ServerContext then you'll need to look at what custom controls are being used - and if I were you I'd comment each one out until the page loads.
    *********************************************************************** Please remember to mark your question as answered and Vote helpful if this solves/helps your problem. Thanks - Mark. **********************************************************************

Maybe you are looking for

  • Error in billing document while posting to accounting

    Hi all, We are geetting an error while the billing document is moving to accounting the error is Please assign a Valid Material code in the Assignment Field please give your suggestions on this and give the what are all the configurations need to do

  • Communications problem with radio link

    A customer has a network composed from a LAN shared-media (with hub 8-ports), a router linked to three modems wich link to three 9.6 kbps radio links. These radio links have linked to another three modems and PC remotes. The problem is that in LAN si

  • Compatibility Chinese and french keyboard

    Hi guys I'm french and I need to write in chinese with my computer the problem is : on tiger, no problems it worked, it reconized my AZERTY keyboard but now on lepard : problem my keybord becomes a QWERTY , not easy to use for a french guy! is there

  • How to setup Recovery drive when upgrading Vista to Win 7.

    I am preparing to do a clean install of  Windows 7 onto a hard drive that shipped with Vista Home and the Recovery partition.  I want to reuse the recovery tools along with Windows 7 in the recovery partition.  I have the original recovery disks.  Wh

  • How to add a shortcut in Firefox to open Thunderbird E.mail program

    What I need to know is how to add a shortcut link so I can open Thunderbird E.mail program while using Firefox. the same as you can open Outlook Express while using MS Internet Explorer by clicking the MAIL button, In other words is there a link to t