Posts

Showing posts from September, 2009

Memory Going Crazy | Life saver

SharePoint likes at LOT of SQL Server memory. For some reason, the more we deploy applications and the more we keep the system running with an hibertate-start, or pure keep-alive status, it just steels me of any memory I have. 500Mb of sql server?? 250Mb of w3wp.exe?? What for?? So I've build a simple batchfile to put the guy back to 50Mb like it should :-p net stop "SQL Server (SQLEXPRESS)" net start "SQL Server (SQLEXPRESS)" iisreset or if its full sql version, not express net stop mssqlserver net start mssqlserver iisreset

List Fields

I underline these fields EncodedAbsThumbnailUrl item in picture list, image thumbnail url EncodedAbsWebUrl item in picture list, image url ATTENTION: Fields are common to all items of a list. Adding or removing fields reflects on all items. List of Fields in Picture Library _________________________________ Field: ContentTypeId Field Type: ContentTypeId Field: _ModerationComments Field Type: Note Field: FileLeafRef Field Type: File Field: Modified_x0020_By Field Type: Text Field: Created_x0020_By Field Type: Text Field: File_x0020_Type Field Type: Text Field: HTML_x0020_File_x0020_Type Field Type: Text Field: _SourceUrl Field Type: Text Field: _SharedFileIndex Field Type: Text Field: PreviewOnForm Field Type: Computed Field: FileType Field Type: Computed Field: ImageSize Field Type: Computed Field: Title Field Type: Text Field: ImageWidth Field Type: Integer Field: ImageHeight Field Type: Integer Field: ImageCreateDate Field Type: DateTime Field: Description Field Ty...

Activating theme | File not found error

Image
After hours looking at this really nice "File not found error", I remembered to go back to my old batchfile wsp installer. Since I need to change the SPTHEMES.XML theme list file, I use Linq, which seems to come up with .NET Framework. Turned out to be missing "System.XML.Linq" reference in the SharePoint Server. Installing .Net Framework 3.5 fixed the problem

No such file or folder error | Theme name cannot have underscores?

Image
Theme activation error: Cannot open "[theme_name]":no such file or folder try removing any underscores from your theme name my_custom_theme -> mycustomtheme don't know why, it just worked for me

Windows XP | Spyware removed "Folder Options"

Some spyware hacks may attack windows xp and disable features such as folder options, unhide files and some administrator commands. Fix this by running both regs: local machine reg current user reg

SharePoint MasterPage | File Not Found Error

Creating SharePoint features is cool because you can create a solution installable package with masterpages, webparts, page layouts and many others within one and only feature, installed with a simply click, available to any site, and capable of being activated and deactivated at any time. But this dreamy capability brings also some issues. One I've found is MasterPage applying. If the process isn't strongly checked, you're sure to come up with "File not found" when activating the feature (God only knows how this error is enlightening) So you SharePoint feature developers out there, keep in mind: There are 3 Site possibilities your "apply" line should check: - SharePoint Web Application (Main or Root Site Collection) - SharePoint Secondary Site Collection (Any Site Collection within the root Site Collection) - SharePoint Subsite Website (Created by "Site Actions" -> "Create Site" Option) Your feature dll should check the sit...

SharePoint Theme | File Not Found Error

Most "File not found" errors on "Activating" themes are due to "SPTHEMES.XML " file location not found. This happens because languages on websites may differ: ENG - @TEMPLATE\LAYOUTS\1033\SPThemes.xml PTG - @TEMPLATE\LAYOUTS\2070\SPThemes.xml The best way to fix this is by calling your SPTHEMES.XML XML Editor Method with the current web language as Theme List folder. Then, if the language folder named after the current website language cannot be found, it means that the user has changed the regional settings to another language, but he does NOT have installed a language pack for that language (LCID folder). So, we go on installing on English (LCID 1033) folder. If both of them fail (for crash prevention) we give up on applying the theme. using System.Globalization; (...) public override void FeatureActivated(SPFeatureReceiverProperties properties) {     using (SPWeb web = (SPWeb)properties.Feature.Parent)     {       ...

SharePoint Language Codes

SharePoint's features are installed into the 12 hive folder C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE Features like themes require a change in SPTHEMES.XML located at C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\1033 However, if your MOSS installation comes in other language rather than english, this folder will differ on the Local ID (LCID). For example, portuguese (ID 2070): C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\2070 This means you have to check the web server's language ID BEFORE make any changes. Language IDs determine the languages used for text in the Web pages, such as text on the Site Settings page. Languages available for site creation depend on the language template packs that you have installed on the server or server farm. Locale IDs control the numbering, sorting, calendar, and date and time formatting for the Web site. You can change the locale for...

Generate Random Numbers and Strings

//generate random number between min and max private int RandomNumber(int min, int max) {   Random random = new Random();   return random.Next(min, max); } //generate random string private string RandomString(int size, bool lowerCase) {   StringBuilder builder = new StringBuilder();   Random random = new Random();   char ch ;   for(int i=0; i&$60;size; i++)   {     ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ;     builder.Append(ch);   }   if(lowerCase)   return builder.ToString().ToLower();   return builder.ToString(); } JavaScript random (needed for on load / refresh updates) var pos = Math.floor((5 - 0) * Math.random()) + 1; //NUM BETWEEN 1 & 5 if (pos == 1) { fade(headerNum); } else if (pos == 2) { SlideToLeft(headerNum); } el...

SharePoint WebParts | Changing List Values, Adding Fields

Sometimes you just want to change field values in lists and it just won't work: SPSite MySite; SPWeb MyWeb; SPList MyPictureList; foreach (SPListItem list_item in MyPictureList.Items) { txtTitle = list_item[“Title”]; //returns correctly list_item["Title”] = “ test”; //does not change value on list } why??? oh god why??? (GOD) my son, you forgot to UPDATE the damn field: foreach (SPListItem list_item in MyPictureList.Items) { txtTitle = list_item[“Title”]; //returns correctly list_item["Title”] = “ test”; //DOES change value on list list_item.Update(); } to add a field: list_item.Fields.Add("textcolor", SPFieldType.Text, false); list_item["textcolor"] = txt_text_color.Text; Note: Strangely I've found that the field is created on all items of the list and not just in the current list item, althought instantiation does... and that's all folks Source: MYSELF

SharePoint 2007 | List All Web Applications in Farm

So you think it would be cool to have a dropdownlist with all web applications from your SharePoint Farm Server? using Microsoft.SharePoint; using Microsoft.SharePoint.Administration; (...) SPFarm spf = SPFarm.Local; SPWebService spws = spf.Services.GetValue (""); foreach (SPWebApplication spwa in spws.WebApplications) { ddl_MyWebs.Items.Add(spwa.DisplayName); } My thanks go to Brian for this great code

SharePoint 2007 | Web Part Maintenance Page | Existing WebPart ID error

Image
- So you're building webparts and the page is crashing? - Are you getting an annoying error that won't allow you to add your webpart saying: "A Web Part with this ID has already been added to this page" - Let's say your site is, for example: "http://myspsite/default.aspx" - You can add "?contents=1" to the browser's adress bar and try to remove some webparts or even all webparts if needed and the error is sure to go away "http://myspsite/default.aspx ?contents=1 " This one is kind of tricky to get to, but you can get it through the browser - "Site Actions" - "View All Site Content" - "Pages" - Hover a page, like "Default.aspx", click the arrow context menu on that file and select "Edit Properties" - On the bottom of the editing page will se an option saying: "Open Web Part Page in maintenance view" Its amazing what you can find on a sharepoint test server homepage Sources...

SharePoint WebPart | Unexpected Error

Image
So you want to create a new web part with custom editable controls in "Modify Shared Web Part" area ERROR: An unexpected error has occurred. Web Parts Maintenance Page: If you have permission, you can use this page to temporarily close Web Parts or remove personal settings. For more information, contact your site administrator. Troubleshoot issues with Windows SharePoint Services. SOLUTION: - Add constructor to editor file, with ID - Make sure your CreationEditorParts() method is returning something - Make sure you add IWebEditable to header and implement the functions public class MyWebPart: System.Web.UI.WebControls.WebParts.WebPart, IWebEditable /* editor part */ public MyEditorPart() { this.ID = "MyEditorPart"; this.Title = "My Editor Title"; } /* main webpart */ #region IWebEditable Members EditorPartCollection IWebEditable.CreateEditorParts() { try { List editors = new List (); ...

SharePoint 2007 | Ajax

Baby steps http://www.codeplex.com/sharepointajax

SharePoint 2007 | Change Central Admin Language

Após instalar pacotes de línguas, pode ser fácil criar novos sites em línguas diferentes. Mas e a administração central que fica sempre a mesma?? Pois é, mais fácil não pode ser. Apesar de alguns campos se manterem, a maior parte pode passar para Inglês, Português, etc. Microsoft SQL Server Management Studio ou outro SharePoint_AdminContent DB dbo.Webs TABLE Mudar campos para 1033 (Inglês) ou 2070 (Português PT) - Language - Locale

Windows 2008 Server 64 bit + Cisco VPN Client

Até à data a Cisco não disponibilizou software de cliente VPN para 64 bits. Algumas soluções que se encontram na net passam pelo uso de OpenVPN com conversão do ficheiro a importar, de .pcf para .conf, ou então usar o Cisco AnyConnect. Para quem não lhe interessar qualquer das soluções, existe o NCP Secure Entry Client. A versão trial dá para 30 dias e parece funcionar. Logo que possível vou testá-la. NCP Secure Entry Client Fonte: Blog de Andrew Murdoch

SharePoint 2007 | Virtual Earth? U Got It

Image
Tester Click Here to Open A Test Site! I recommend: (Sadly this one only works for US states, unless you change the source also available at codeplex to allow lat/long fields) VirtualEarth WebPart @ CodePlex http://www.codeplex.com/VirtualEarthWebPart SharePoint Designer Team Blog http://blogs.msdn.com/sharepointdesigner/archive/2007/05/23/plotting-your-data-using-virtual-earth.aspx WebCast "SharePoint Mapping" by Ricardo Calejo http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032409401&Culture=pt-PT

SharePoint 2007 | Central Admin Installs WSP files!

Image
Cool addin that allows your central administration solution operation to add WSP packages, "browser-friendingly" GET IT HERE After adding, it's time to install it: I've took Nick's webpart and build an installer with solution installer You might have to got to your website's site features and activate the packages you install. Still, couldn't get easier! Source: http://www.sharepointblogs.com/nicksevens/archive/2009/01/12/add-wsp-solutions-through-the-interface.aspx