Hot answers tagged

33

There's an out-of-the-box way to remove the Add new item link. If you edit the webpart properties using the Modify Shared Web Part command, you'll find the Toolbar Type dropdown in the List Views section. If you choose No Toolbar there and save the page, the footer link will be gone. No code required, no unghosting/customization, and no effect on other web ...


19

Short explanation: As far as usage is concerned, in many common cases there are almost no actual differences - anything you can do with a webpart you could do with a visual web part. For many points of view the visual web part is only a tool that enables the developer to work with a user control instead of creating all controls in codebehind. Visual web ...


18

Here is my fix to the problem. It seems in SharePoint 2013 calling ExecuteOrDelayUntilScriptLoaded() doesn't work on published pages. This is the correct way to do it according to Microsoft (see: http://msdn.microsoft.com/en-us/library/jj245759.aspx) // Make sure the SharePoint script file 'sp.js' is loaded before your code runs. ...


17

Yes. You need to activate Site Feed feature in Site Settings --> Manage site features. Then, when adding web part, under Site Collaboration group you will have the Site Feed WebPart UPDATED Yo must activate this feature in _layouts/15/ManageFeatures.aspx


17

The Announcements list seems to be the most obvious choice to me. Rich text capabilities, expiration so it will automatically disappear from web part views on the main page, audience targetting.


17

Never put SPContext.Current.Site (or web) into a variable in a using statement. You're not allowed to dispose them, they are passed on to the next web part and SharePoint will dispose them when done. So change using (SPSite oSPSite = SPContext.Current.Site) { .... } to SPSite oSPSite = SPContext.Current.Site; ....


16

I usually use SPUtility.Redirect when working with Application Pages or pages that need to potentially look at the source querystring or go back to settings.aspx. If I am doing a redirect other times (usually in an HttpModule), I will use the Context.Response.Redirect or HttpContext.Current.Response.Redirect. The Page.Response.Redirect is just exposing the ...


16

If you just want to hide it, you can use following css (you must override sharepoint core css with your custom css file) td.ms-addnew{ display:none; }


15

You can always add ?contents=1 to any url in SharePoint to see what specific webparts that are used in the site/page. Example: http: //test.sharepoint.com/Pages/default.aspx?contents=1


14

You can create a feature and on the activation of the feature you can add the webpart to the page. public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPSite site = properties.Feature.Parent as SPSite; using(SPWeb web = site.OpenWeb()) { using(SPLimitedWebPartManager wpManager = ...


14

I'd avoid branching as it will get very difficult to manage when multiple webparts are under different parts of development. Been there - a messy code handed to me and had to figure out better way to maintain. This kind of issues crop up due to "type-based" project structure, where all webparts are under "WebParts" project, all features are under ...


14

The best way to do get a quick view of what is being used where in a given content database is with the stsadm command enumallwebs using the addtional parameters supplied with the October 2009 Cumulative Update: stsadm -o enumallwebs -includefeatures -includewebparts -includeeventreceivers -includesetupfiles -includecustomlistview There's also a useful ...


13

You should remove <Query> and </Query> and use only inner XML. So in your case the .Query should be: itemsByDateQuery.Query = "<Where><Geq><FieldRef Name=""EventDate"" /><Value Type=""DateTime""><Today/></Value></Geq></Where><OrderBy><FieldRef Name=""EventDate"" Ascending=""True"" ...


13

You can't deploy a Web Part at the Scope = Web level. Web Parts must be deployed at the Site level since the .dwp or .webpart file needs to be deployed to the Web Part gallery, which is at the Site Collection level.


13

My general rule of thumb on application page versus web part is re-usabilty...i.e. do I need to surface the capability in more than one location within a site. If I'm only going to surface a single instance of the functionality then surfacing that capability via an application page is the way to go because they are much easier to build, deploy, and maintain ...


13

Like Bill mentions, the SharePoint web part is primarily there for backwards compatibility, although it does provide 4 features that are not available in the standard asp.net web part:- Cross page connections Connections between Web Parts that are outside of a zone Client-side connections (Web Part Page Services Component) Data caching infrastructure, ...


13

You cannot open that web part from "Web Part Maintenance Page" again. Instead you have to "Edit Page". Then click "Add web part". From left pane, in the categories click "Closed Web Parts", and then select your closed web part to be restored.


12

Each webpart zone has a property called "Orientation" <WebPartPages:WebPartZone runat="server" AllowCustomization="true" AllowPersonalization="false" ID="MiddleTop" Title="Middle Top Zone" Orientation="Vertical"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone> Change this to "Horizontal" and they will show side by side ...


12

SharePoint solution packages consist of a .WSP file that you can create using Visual Studio (or manually if you so wish). Before deploying to a production environment, I recommend you take a look through Deploy solution packages (SharePoint Server 2010). Basically you need to add your solution to the solution database of a SharePoint Server farm using the ...


12

SharePoint also provides the _spBodyOnLoadFunctionNames function, which allows you to specify what script to run on page load. If you specify your function there, it is less likely to interfere with SharePoint's own script.


12

You can certainly do this for Content Query Web Parts, but beware that some web parts might be sealed. If you use ILSpy you can view the SharePoint Assemblies to gain understanding of how the OOTB web parts work. Here's a link to ILSpy: http://wiki.sharpdevelop.net/ilspy.ashx Here's a link to Andrew Connell's blogpost on extending the Content Query Web ...


12

I came across this link by Josh Gaffey that describes how to set the welcome page for a publishing site. The code I used is: ... // Create publishing page if (bPageCreated) { using (SPSite site = new SPSite(p_sSubSiteUrl)) { using (SPWeb web = site.OpenWeb()) { PublishingWeb publishingWeb = null; if ...


11

AFAIK, DefaultValue attribute won't work for webpart properties. You can use .webpart file for setting default values to your properties. You will need to add new <property> element under <properties> tag, like following: <property name="sectionToRead" type="string">CV</property>


11

According to the documentation there's no such an attribute on FieldRef as "Descending" - there is an "Ascending" one: <FieldRef Alias = "Text" Ascending = "TRUE" | "FALSE" CreateURL = "Text" DisplayName = "Text" Explicit = "TRUE" | "FALSE" Format = "Text" ID = "Text" Key = "Text" List = “Text” Name = "Text" RefType = "Text" ...


11

Glyn Clough has a nice solution for exporting xsltlistviewwebpart Update 2014-09-19 I have found another way to easily export any web part from a SharePoint page, without needing to update web part properties: Export any web part from a SharePoint page Here is the most important text from the blog post: In SharePoint there is a hidden application page ...


11

The reason is that you are hijaking the onlod event from the SharePoint javascript. See this post for help http://haacked.com/archive/2006/04/06/StopTheWindow.OnloadMadness.aspx


11

go to pagename.aspx?contents=1. This will let you manage your webparts


11

When you deploy a solution with a WebPart it deploys three things: The dll with the web part A SafeControl entry to be inserted into web.config A .webpart (or .dwp) file with configuration settings to be inserted into the Web Part Gallery (this part actually happend at feature activation not at solution deploy, but..) When you're adding a web part to a ...


10

I found a solution for this problem. below code should be added to ascx file <%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <SharePoint:ScriptLink name="clienttemplates.js" runat="server" LoadAfterUI="true" ...


10

You need to populate the gallery if web part is not appearing in the web part gallery. For that go to site setting(I use 2013) site gallery, click on web parts link There clicking on new documents, you will get all the web parts installed. Check the box along the web part name and click on populate button on the top. That should work, I hope.



Only top voted, non community-wiki answers of a minimum length are eligible