How do you disable a SharePoint webpart temporarily? - sharepoint

Can this be done by setting a property?
I'd prefer that approach then to remove all security before re-adding it.
(As this may have other consequences.)
Another option I can think of is to replace the particular webpart dll with a temporary one, and restart the .net process, but that's not an approach I like at all.
What other options are there? AM I missing something obvious?
What i'm trying to do is find a way to disable a webpart while we update the underlying database schema it's using, for example.
So we'd ideally like to disable a specific webpart for all users, whether it's on a mysite, or a community site, make the required changes and then re-enable it.
Thus decreasing the downtime for users.
Whatever the solution is, we need to be able to do it across multiple front end servers, on potentially two farms easily.
Thanks for your help.

Go to Site Actions -> Edit Page
You get all the web parts edited. Click on the "Edit" dropdown of the Web Part you want to disable and choose "Close".
The web part disappears, but don't fear! It's not gone for good!
To have it back:
-> click to Add a new Web Part -> Advanced Web Part Gallery and Options.
The very first option you have is to choose among "Closed Web Parts". When clicking on that link, you will have displayed a list of all the web parts you had closed. Just add the one you want back!

In the web.config, you can set safe="false" for the SafeControl tag for the webpart. This will cause the web part to render an error message until you set it back to true.
http://technet.microsoft.com/en-us/library/cc287909.aspx

write code to set a value in property bag of the site, set the value through the code and in page lode of the web part check for the value of the property bag if set show the content else just skip.
hope you understood if not let me know i will make it clear.

Related

SharePoint 2010 List disabling edit even for people with Manage permissions

this seems to be a bit of an odd requirement, but we have a separate form (not an infopath form) being filled out by people. Now, this form that we have has quite a lot of validations in it. We're currently trying to prevent people from accessing the list where this certain form is saving the data, this is so that they won't bypass the validations we created in the form that we created. Is there a way to be able to do this, one way or another?
Easy fix. Use SharePoint Designer to browse to the list, starting from "All Files". The list has several files in it. You're only interested in NewForm.aspx and EditForm.aspx.
Open these files. Either add JavaScript redirect code directly to the file (near placeholdermain) to point back to AllItems.aspx, or add a Content Query Web Part to add the redirect JavaScript code in that added web part.
Either way, when users go to add/edit items in that list, they will be bounced back to the page that list the items.
This will only work when JavaScript is enabled. Mind you, SP won't work very well with JavaScript off anyway, so people may not disable JS. But for a bullet proof solution, make a Visual Studio feature for the specific list.

How to find missing web part?

Does anybody know how to find offending web part which causes this error ?
“A Web Part or Web Form Control on this Web Part Page cannot be displayed or imported because it is not registered on this site as safe.”
I have inherited an old SharePoint 2003 portal site which uses custom web parts.
I know what this error means. I also know that each web part must be installed and registred as safe in web.config. The problem is that I don't know which one is missing.
I get same error when I'm trying to open the page in FrontPage as well.
Use contents=1 in QueryString to disable/remove WebParts from page that causes errors.
stsadm.exe -o enumallwebs -includewebparts
http://sharepointreporter.wordpress.com/
Requires updating to Sp2 I believe, for this command to be available. Problematic web parts will appear as 'Missing' in the resultant list.
Go to Event Viewer of the machine and you shall be able to see Error entries. Out of tons of entries you have to find out the entries related to you and you shall be able to see the names of the webparts that the sharepoint site is trying to load but fails. If you shall read the complete description of the error entry in the Event Viewer, it will give you version and even PublicKey Token of the webpart as well.
I hope this helps!!!
Try reading this:
http://www.bluedoglimited.com/SharePointThoughts/ViewPost.aspx?ID=189
It should give you some clues to solving the problem. Essentially you have a control that is not marked as safe and it is failing. You can most likely config it to work, but the link above has other possible solutions.
in your url just append content=1. This will give you the all the webparts that are deployed. Now, you can keep deleting each of the webpart to find which one is causing issue ( ensure that you know to add the web parts back).
For example: if Url is http://localhost:9000/default.aspx, try with http://localhost:9000?contents=1
Alternatively, try to create a new webpart page,add web parts that are there on your actual page and check which one is causing issue. This will avoid changes to the actual page.
Hope this helps.
I've just suggested this same answer on MSDN:
This stsadm helped me in finding where the webpart was referenced in any way:
stsadm -o enumallwebs -includewebparts > C:\temp\somelog.txt
Then you can see the web part is listed under some <Web Id=... Url=...> XML node, i.e. you know the "culprit" web site.
At that point, some reasons I've found for those forgotten references:
the webpart is used in some sub-site of the culprit website, and the sub site is hidden from the quick list or top bar
the webpart has been deleted from the culprit website, but it still is in the "site collection recycle bin". You can reach that by going to the normal website recycle bin, then look for its link on the top bar description ("Use this page to restore items that..."). By the way, this site collection recycle bin has two views itself: be sure to check them both.
In both cases, I got some help by browsing the culprit website with SharePoint Manager. With that I could easily spot the existence of a forgotten subsite, as well as the existence of this "second level recycle bin".
HTH

Load a web part before other

I am stuck with a problem. I am having tool part where I get all the Lists present in the Site.
I have other web part which should get the selected List in the tool part.
I see that the web part is loaded first then the tool part. so the web part is unable to the List selected in the tool part.
Please note that the text box is in a User Control.
Please help me.
I have looked at your code and found the following:
First things first. You need to move AWAY from using ToolParts and the SharePoint native webpart. they are deprecated and are a remnant from SPS2003. In MOSS / WSS 3.0 you can and should use the ASP.NET WebPart.
Secondly, I think you are mixing things up. The ToolPartGetLists is not a toolpart, it is a webpart, that in itself loads the CustomToolPart, which in turn allows you to select a list.
This toolpart is only shown when you edit the shared webpart in the UI. The list you select is then persisted to the SelectedList property of the webpart using the toolpart.
The connected webpart then tries to read the SelectedList property I guess.
Like I said, I could go and try to fix the code for you, but it is not the way to go, you really (REALLY) need to switch to ASP.NET WebPart based webparts. The native sharepoint one WILL be fased out in the (near) future.
Here you can find an example, with code! (scroll to bottom for download link). As a bonus, it uses the built in sharepoint listpicker
I don't know of any way you could control the load order of elements (web parts) on the same page.
Sounds more like you want to have your second web part (the display of the lists) have a "default" when the page loads--which could be empty. Then it would be changed to the selected list only when the user clicked a new selection in the other web part (the list of lists).

SharePoint error relating to page layout after creating site from template

Inside SharePoint I've previously created a site template by appending _layouts/savetmpl.aspx to the end of my site and new sites have been created correctly and work as expected.
I've now come to do the same thing again and yet this time the new site is throwing an error relating to the page layout.
The error is:
This page is not using a valid page layout. To correct the problem, edit page settings and select a valid page layout.
When I try to select a different one, there is only the one to select. This page layout is in use on other sites and they render fine.
Has anyone else seen this issue?
All the best
First, if you append the _layouts/savetmpl.aspx tho the url, i suppose you dont have it in the Site Settings options, so you are using a Publishing site. This is because Microsoft doesn´t support this option (save as template in publishing sites). And they dont support it because it has some bugs, for sure.
So, I would recommend not using this option in important sites, or if you plan to ask support to Microsoft in the future.
However that error indicates that the page layout or his associated content type (ou parent content types) are not correctly installed in the site collection. Are you using your own (custom) content types? Please confirm if the ID of the associated content type (something like 0x0100C6739B7D12DE419aA2F9A2F96CC26818) is exactly the same in the Page Layout on working sites and in the not working sites.
Hope it helps
Do the sites/site collection where the templates working have all the same features enabled as teh sites/site collection where the template isn't working?
Can you check the server logs? <12 hive>\LOGS
Did you add a custom page layout, use it, and then forget to check that "save content" checkbox when you saved your template?

Can Web Parts in Sharepoint be moved outside of edit mode using drag & drop?

I'm wondering if anyone has implemented an iGoogle/netvibes drag&drop interface in the normal view mode of a Sharepoint 2007 Web Part page? I would preferably want to use the drag & drop functionality that already exists in the edit mode if possible since this comes with Sharepoint, but I want this to be available in the normal view mode of the page, not just in edit mode.
I've looked around the net for this but can't find anyone who has done this. I tried a quick test using jQuery but the markup of the page by default makes it difficult to implement with its table based layout.
I've also seen that there's a table cell sorting implemented with YUI that might be usable for this but I haven't tried it out.
So, any tips would be greatly appreciated if anyone has any experience with this!
SharePoint stores the details of where a web part is on the page in it's database. When you move the web part around in edit mode you're changing it's Zone property value in the content database. So if you were able to drag and drop the HTML for the web part you'd also need a way to update the database to let SharePoint know its new position next time the page loads.
I guess this is possible using AJAX to make a call to the server to update the web part's zone but I haven't seen this done anywhere.

Resources