Tag Info

Hot answers tagged

31

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 ...


17

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 ...


16

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.


16

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 ...


15

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

Here is my fix to the problem. It seems in SP 2013 calling ExecuteOrDelayUntilScriptLoaded() doesnt work on published pages. In SP2013 this is the correct way to do it according to MS @ http://msdn.microsoft.com/en-us/library/jj245759.aspx // Make sure the SharePoint script file 'sp.js' is loaded before your // code runs. SP.SOD.executeFunc('sp.js', ...


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

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 ...


14

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


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

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 ...


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"" ...


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

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'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.


12

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 ...


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

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

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


11

You can add ?contents=1 to the current page url to view a 'web parts maintenance page'. From there you should be able to see the web parts on the page, the type, and if they're open or closed.


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

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

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

The difference between SPUtility.Redirect and Page.Response.Redirect is that SPUtility.Redirect provides many more options while redirecting. SPUtility.Redirect takes in the SPRedirectFlags enumeration as one of the parameters which gives us more control over the redirection. With it we can even keep the reference of the previous page. More details on the ...


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

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 ...


10

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.


9

One important thing is the performance aspect! Application pages are compiled when first accessed whereas site pages are not compiled. Another important aspect is that Site Pages does only support controls marked as SafeControls and inline code is not possible (without fiddling with security).



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