Tag Info

Hot answers tagged

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

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


11

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


10

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


10

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


10

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


9

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


9

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


9

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


8

Your SelectedTabs property should be persisted. Try use this code: [Personalizable(PersonalizationScope.Shared), WebBrowsable(false)] public List<ListItem> SelectedTabs { get; set; } Update: Also, you should not store ListItem's. I changed List<ListItem> to List<string> and fixed some code, and it is working on my machine now. Here is ...


7

Use the SPLimitedWebPartManager.MoveWebPart method: string zoneId = "TopZone"; // ID of the WebPartZone control string zoneIndex = 0; // Location of web part within zone string webPartTitle = "Sales Tips"; // Title of web part string filename = "default.aspx"; // Filename relative to SPWeb object using (SPLimitedWebPartManager ...


7

I hope this can help you, althought I have not tested it. You can find an example here: http://www.sharepoint-tips.com/2010/06/validating-web-part-properties.html private string _webPartContentLink = null; [Personalizable(PersonalizationScope.Shared)] [WebBrowsable(true)] [System.ComponentModel.Category("Services")] ...


7

This is almost certainly due to the lack of caching on the content coming from the external site. How long does a request to the site normally take? Consider adding some caching, or displaying the content on your page asynchronously. And indeed, are you sure that you've not got a hidden list somewhere being used as a cache? i've seen that done. I presume ...


7

Also check that you dont have a version of the assembly in the BIN folder of your IIS website. Note that it is considered a best practice to package your web part in a solution (WSP) and deploy it this way. Also as noted in SO answer, make sure that you are hitting the right WFE. If you have several web frontend servers, you must manually update all GAC's ...


7

First of all you're doing the number one mistake when building Web Parts (or ASP.NET controls for that matter). Never ever write code like this in the Render() method. Use the CreateChildControls() preferrably (IMHO) and if that not suits you use RenderContents(). If you're using/overriding the Render() you can break all kinds of things. Then; never ever ...


7

You have a couple options here (...I've used both successfully in the past): 1) Call _spBodyOnLoadFunctionNames.push("function()"); replacing function with the name of the function in your webpart. This will cause your function to be executed after the body of the page if fully loaded and in sequence with other startup client-side scripts. 2) You can go ...


7

The function below will get you the UserProfile based on the accountName public static UserProfile GetUserInfo(string AccountName) { UserProfile profile = null; SPServiceContext serviceContext = SPServiceContext.Current; UserProfileManager profileManager = new UserProfileManager(serviceContext); if (AccountName != string.Empty) { ...


7

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


7

It is not safe to store credentials, connectionstrings or similar in web parts. All users with contributor (designer in SP2010) settings and upward can export the web part and fetch the values from the .webpart/.dwp xml. You can set the web part to not allow export, or not to export sensitive data (sensitive data is set on using the IsSensitive parameter ...


6

Put this in a content editor webpart <script> setTimeout(function() { var elem = document.getElementById("MSOZoneCell_WebPartWPQ2"); if(elem != null) { var dummyevent = new Array() dummyevent["target"] = elem dummyevent["srcElement"] = elem WpClick(dummyevent) } }, 2000) </script>


6

Sounds like you are missing the <SafeControl> element from your package. Normally it is added for you if you create it in VS2010. But if your web part/control is in another assembly you may have to add it manualy http://msdn.microsoft.com/en-us/library/ms412965.aspx Something like this should go in your Package.Template.xml file (Solution explorer -> ...


6

Is it possible to do a similar trace on the external web page you are getting your data from? If this page is suffering from the performance inconsistency you may have found your culprit. If not, can you replace the external page with a mocked up static page that you control? If you can control the datasource it will help you ensure that anything you are ...


6

To "hide" it from the WP gallery you just leave out provisioning the Web Part Control Description file (.webpart) (in VS2010 - just remove the .webpart file). You will still be able to add your Web Part in server side code or by directly adding it in the WebPartZone in the page (via a feature that deploys the page or using SPD customizations). PS: To stop ...


6

Web Part Pages are advantageous when you want to display information within your site in a different manner. They can be viewed very similarly to sub-sites because you can add them as links to your quick launch just like sub-sites however, they do not require you to create an entirely new site (which could contain new security groups, possibly pre-created ...


6

Definitely passing webpart values to XSLT is possible for all classes which inherit from DataFormWebPart, and can be easily done through ParameterBinding: <ParameterBinding Name="WPPropertyBinding" Location="WPProperty(Title)" /> Use your custom property name instead of Title. If you're using a standard SummaryLinkWebPart and you need only to fix ...


6

Usually in Page_Load or in CreateChildControls you should place the check for IsPostback and load the data only if the page is not in the postback mode. And also, you should load the data in all postback handlers. This way, the data is loaded always and only once per page load. But while this solution will work perfectly for a separated page, things get ...


6

I would recommend you to store things like connection strings in secure storages. For example, SPWeb.Properties require only read permission for site, and they can be revealed easily by any advanced user, for example using SharePoint ECMAScript Client Object Model. So if you store user name and password for accessing DB in the connection string, it would be ...


6

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. But you'll have to ...


6

This is a common problem when using multiple JavaScript libraries as many of them define $() SharePoint is using ASP.NET Ajax so if you include JQuery you should do that in noConflict mode. You turn that on using jQuery.noConflict(); Now $ will never mean jQuery unless you use constructs like: jQuery(document).ready(function($){ /* code using $ */ ...


6

Visual Studio deploys to the server it's installed on, and as a best practice it shouldn't be installed on any production server. During the deployment process, the applicable bits for the solution will automatically be "deployed" to any server in the environment with the Foundation Web Application role. For deployment to production, the correct process ...



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