![]() |
|
Spaces home Michael's Coding DenProfileFriendsBlogMore ![]() | ![]() |
|
July 02 2008 MVP AwardHurray, got the 2008 MVP Award today! They re-awarded me again, since year 2005 in [.NET/C#] area for my achievements in “online consulting” ;) But this year I’m Australian MVP!
Thinking about changing the area and become SharePoint MVP in the next year :) June 13 SharePoint Designer removes tags when saves page layout - “file system” feature workaroundIn the current project we are using SharePoint Designer 2007 intensively to create number of PageLayouts, especially to put WebParts there and pre-configure WebParts connections. SPD is not such a bad tool, because there is no alternative for this. But time to time it really buggy and awful that you start thinking if it passed QA team before being released. (event SP1 doesn’t solve a lot of common crucial bugs, which stops you using SPD at all) The most disgusting stuff of SharePoint Designer is that it formats your pages markup without asking you. And what’s worse it REMOVES some tags. I really can’t understand that behaviour – WHY it removes what you typed when you save document?! Recently, we stumble over the very nasty thing of SPD – accidental formatting. We have a PageLayout with several web parts on the page and we created <SPWebPartConnections> section to predefine WebParts connections. But whenever you save your document, SPD for some reasons removes some of your <SPWebPartConnections>. We spent about 2 hours to understand any dependencies or logic, but without success. It seems that they have some kind of RAND which selects which of the SPWebPartConnections tags to remove. We tried to install several hotfixes for SPD – but nothing works. So, the only way is to use other tools, like Visual Studio. But there is a problem. If you are edit your pageLayout in Visual Studio and want to test it, you need to re-deploy your pagelayouts each time, because VS doesn’t support check-in/check-out to SharePoint Content DB. But there is alternative way to edit your pages and have check-in support from the Visual Studio. SharePoint has very cool “file system” feature. It means that you can navigate to your PageLayouts from explorer, open them in any editor and save it back. All your changes will be stored in Content DB(!!) To do this your need to open Windows Explorer and navigate to My Network Places. On the left side you will see the “Add Network Places” item. Open it and type there “http://<yoursite>/_catalogs/masterpage/”, type the name of your network folder like “MySite PageLayouts” and press OK. Now, if you open the “MySite PageLayouts” item from Windows Explorer->My Network Places you will see the content of your “_catalogs/masterpage/” SharePoint folder. And now your can open your masterPage or PageLayouts in any editor, edit them and save them. All changes will be stored into ContentDB. But don’t forget to checkout your file before editing (via Sharepoint or SPD) So, this trick allows you to edit any SharePoint files and forget about SharePoint Designer issues Mirror: SharePoint Designer removes tags when saves page layout - “file system” feature workaround June 05 Page events stop working after using output stream for binary downloadIn my previous SharePoint projects I've met the situations when you need to outstreem some binary files, like PDF file or something else, but when you do this by the standard way (how you used to do in normal ASP.NET site) you found that page is "dead" after you streamed you file to the client. By "dead" I mean that it doesn't respond to any events, and you can't use this page. The problem lies in the SharePoint JavaScript files, which are integrated into the each web page, and seems that they protect you from unnecessary double-posts. But unfortunately such behaviour breaks your stream output. I didn't have a change to investigate this problem in details, to find out what exactly affects on this, and always solved this by putting stream out in the new popup window. In these days on SharePoint NGs this question was risen and "andyspears" posted a work-around, how to change the SharePoint JS and return the normal behaviour back. 1: //1) Set your button's client-side click event to: 2: "exportRequested=true;" 3: 4: //2) register the following JS: 5: string beforeSubmitJS = "\nvar exportRequested = false; \n"; 6: beforeSubmitJS += "var beforeFormSubmitFunction = theForm.onsubmit; \n"; 7: beforeSubmitJS += "theForm.onsubmit = function(){ \n"; 8: beforeSubmitJS += "var returnVal = beforeFormSubmitFunction(); \n"; 9: beforeSubmitJS += "if(exportRequested && returnVal) 10: {_spFormOnSubmitCalled=false; exportRequested=false;} \n"; 11: 12: //beforeSubmitJS += "alert(returnVal + '\\n' + _spFormOnSubmitCalled);"; 13: beforeSubmitJS += "return returnVal; \n"; 14: beforeSubmitJS += "}; \n"; 15: 16: //beforeSubmitJS += "alert(theForm.onsubmit);"; 17: this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alterFormSubmitEvent", beforeSubmitJS, true); Thanks AdnySpears, good work! Mirror: Page events stop working after using output stream for binary download May 28 Subclassing Content Query Web Part to override CAML queryThe Content Query Web Part (CQWP) in MOSS is one of the popular out-of-the-box Publishing components which is used in content management sites, allowing you to get results from different sources. But sometimes out of the box functionality is not enough to meet your requirements, and you need to customize CQWP. There are several resources describing how to do this - 1, 2, 3, 4 The most important features which are missed in CQWP are:
To implement these functionality you need to subclass ContentByQueryWebPart class and override several methods. Below I will describe what exactly need to be done to achieve desired behaviour. Query Override To have custom CAML query in your Web part you need to override CreateChildControls base method. You can find samples how to do this in the references above, but it's done so implicitly, that you can easily spend hours to find out why you code doesn't work and gives you different errors The crucial part is in the way sending the query to the base class within overrided CreateChildControls 1: protected override void CreateChildControls() 2: {3: this.QueryOverride = customQueryString; 4: 5: base.CreateChildControls(); 6: 7: QueryOverride = string.Empty; 8: 9: CommonViewFields = string.Empty; 10: }First, you need to set your custom query to the "this.QueryOverride" to inform base class about query - line 3 Second, call base CreateChildControls() allowing your query being executed - line 5 Third and last - CLEAN query and view fields properties - line 7,9. Without this step you will get errors when open your Web Part in edit mode Enabling Connection The Content Query WP doesn't accept any connections by default. You need to implement this too. Everything you need to to is just add ConnectionConsumer attribute. But trick in setting the right attribute which is used in Parameter dialog box, when you connect two web-parts. 1: [ConnectionConsumer("Another WebPart", "IFilterValues", AllowsMultipleConnections = true)] 2: public void SetConnectionInterface(IFilterValues filterProvider) 3: {4: if (filterProvider != null) 5: {6: // save provider with values 7: providerValues = filterProvider.ParameterValues;8: _filterProviders.Add(filterProvider); // variable declaration is List<IFilterValues> _filterProviders = new List<IFilterValues>(); 9: List<ConsumerParameter> parameters = new List<ConsumerParameter>(); 10: 11: // add params 12: parameters.Add(new ConsumerParameter("param1", 13: ConsumerParameterCapabilities.SupportsSingleValue | 14: ConsumerParameterCapabilities.SupportsEmptyValue));15: parameters.Add(new ConsumerParameter("param2", 16: ConsumerParameterCapabilities.SupportsMultipleValues | 17: ConsumerParameterCapabilities.SupportsAllValue | 18: ConsumerParameterCapabilities.SupportsEmptyValue)); 19: 20: filterProvider.SetConsumerParameters(new ReadOnlyCollection<ConsumerParameter>(parameters)); 21: 22: } 23: }Method name can be any, but pay attention which provider you are using . WebPart providers send data via different provider interfaces, for example when you are working with Filtering web parts (like "Current User Filter" web part) then you need to "listen" your incoming connections via IFilterValues (thx Mutaz for this findings), for other WB it could be IWebPartField or IWebPartRow. If you are expecting to get data from WP via unsupported provider you connection link will be dimmed Practical Sample @d2design kindly asked to provide practical sample, for example how to use current user as a keyword :) Actually, it's good example which shows how use both features I described. To do this you need to have:
TIPS:
Mirror: Subclassing Content Query Web Part to override CAML query May 22 MOSS Content Deployment Jobs - Lookup Fields and requirementsContent Deployment Job is a nice feature of MOSS 2007 to secure your main site from unauthorized and accidental changes and have approved content being deployed via standard MOSS functionality. But Content Deployment Jobs are a bit tricky :( There are some areas which I'd like to highlight in the current post, which helps you to save hours in configuring Content Deployments Path and Jobs Requirements To have successful contend deployment you need to prepare your sites correctly. There is a great post from Stefan Gossner who provided detailed explanations to all pre-requirement. Just to summarize, you need:
Incremental Deployment When you set deployment path and created your first job you need to do full deployment ("Deploy all content" option) first, and after it's done set the incremental deployment. Your incremental job could fail with the next exception
The reason is that SP1 for MOSS changed the document versioning system, but no changes where done to Content Deployment Job functionality. To solve this issue you may need to install the following hotfix http://support.microsoft.com/kb/950279 or disable minor versioning for specific lists (google to find details about this) Lookup fields The biggest trick in Content Deployment Jobs relates to Lookup fields deployed via Feature. I think that the following exception will be familiar for those who tried run Content Deployment Jobs for Site with Lookup Fields feature
The problems is exactly in deployment scripts of Lookup fields. There are several samples how to deploy lookup fields via feature (http://www.sharepointnutsandbolts.com/2007/04/feature-to-create-lookup-fields-on.html) but all of them are not suitable for the Content Deployment Jobs. Because you will get the exception which I posted above. The only way to find out why this happens is to use 3rd party tools (SharepointSpy or FieldsExplorer) to compare the SchemaXML of Lookup Fields after deployment via FeatureReceiver. So, after scrutinizing this issue I found out that deploying Lookup Fields via FeatureReceiver differs from Lookup fields create via Central Admin Web site. FeatureReceiver deployment adds additional attribute "xmlns="http://schemas.microsoft.com/sharepoint/" to the Lookup SchemaXML which breaks the Content Deployment Job. So, the solution is simple - verify the published schema in FeatureReceiver before calling Update() method for Lookup Field and remove this attribute.
Mirror: MOSS Content Deployment Jobs - Lookup Fields and requirements May 20 Publishing Content Types and missed "CreatePage.aspx" page in WCM sitesSharePoint content types is very popular thing, and used in almost all Sharepoint projects. Deployment of content types via feature is described in almost every book about SharePoint, but non of them describe how to do in correctly :) This happens mostly because the real nature of deployment content types reveals in Web Content Managed (WCM) projects, where you are working with content types inherited from publishing types. And there is no Sharepoint WCM book yet. So, what's exactly specific in publishing content types for WCM? It's the nature on publishing types and using content types in publishing lists, such as "Pages" for example. If to follow the standard practices in deployment of content types via feature, but inherited from any "Publishing" types and then add your custom content type to specific list (let's consider "Pages" list) you will find a bit strange results. Adding new custom publishing content type pages will fail in that scenario - you will be redirected to "UploadPage.aspx" page, not to "CreatePage.aspx" page where you usually create new pages for your custom publishing content types. The problem in that, if you create the content type inherited from publishing types, and don't specify the "CreatePage.aspx" template pages explicitly then you will loose the ability to create new pages for your content types in list toolbar menu (like on the screen above).
The workaround is next - add the reference to "CreatePage.aspx" template explicitly using the <DocumentTemplate> tag inside the <ContentType> feature tag. The code-snipped is following <ContentType ID="0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900<GUID>" </ContentType> When you deploy this content type via feature and add this content type to the list, "CreatePage.aspx" become available and you could create your publishing content via list toolbar menu. The work is done :) Another trick is how to make your publishing content type available in specific list during feature deployment. For this reason you need to use following tag inside feature deployment xml <ContentTypeBinding
Mirror: Publishing Content Types and missed "CreatePage.aspx" page in WCM sites May 14 Sharepoint Tools Overview for Windows 2008 and Visual Studio 2008I used to use a couple of tools in WSS/MOSS development which covered 90% of all functionality. These tools are
but when I switched on Windows 2008 Server + Visual Studio 2008 I noted that these tools are not supported there. Sharepoint Spy can't be installed on Windows 2008 (actually I can, but u need to use ORCA and change MSI); WSS Extensions works with VS 2005 only, and you can't use them with TFS builds. Well... there is another reality, where you can survive without these tools :) There I'd like to post the list of other tools which help you to substitute the Sharepoint Spy and WSS Extensions
I welcome if you post in comments other tools which help you in Sharepoint development, deployment and debugging Mirror: Sharepoint Tools Overview for Windows 2008 and Visual Studio 2008 CSS and ASP.NET Menu in SharepointUsing CSS in SharePoint differs a little bit from the standard approach we use in ASP.NET applications - some styles doesn't work as they expected to work. The major problem is that SharePoint doesn't understand some CSS applied on ASP.NET сontrols. I stumbled over several cases. There is a simple rule how to avoid this - just use the SharePoint controls instead of ASP.NET once. In this cases CSS will be applied correctly The nastiest thing I remember about CSS and Sharepoint is using asp:Menu control :) This control is very dodgy under normal asp.net sites, but it's double dodgy under Sharepoint. The situation is that - you have page area height equal 100% of client browser height. It means that if you change the size of your browser window page layout height is changing too. On this page we have navigation which is implemented via <asp:Menu> control. So far so good, but there is a small issue. If you navigate on menu and dynamic sub-items are shown your page height changes and you noticing that vertical scroll bar is shown. WTF you could think :) Why this scroll bar appears?! This never happens in ASP.NET sites. The answer is - CSS "min-height" property. This property sets the minimum height of your page when scroll bar appears. So, what you do is just edit your page and add the .min-height: 2000 for the page's root element and test the page in browser. Unfortunately, situation the same - scroll bar appears when your menu items are shown. You can use IE Dev Toolbar of other tool to debug DOM model in browser, but changing this property doesn't help at all. The issue is exactly in <asp:Menu> control. I dunno why but it breaks the page CSS style of min-height (I'd pleased if someone explain me WHY and HOW this happens?!). To fix this you need to use <Sharepoint:AspMenu> control instead of <asp:Menu> and min-height is set correctly in this case - no scroll bar when you navigate on menu. Export Sharepoint List Definition with OCDExportList and reusing standard ViewsWhen you are engaged in SharePoint development under Windows Server 2008 you are limited in 3rd party tools, because not all tools are working there, for example you can't use Sharepoint Spy - it requests Windows Server 2003 only (actually you can run Sharepoint Spy by modifying MSI and removing Windows version check) There are some other tools which support Windows 2008, one of this tools is "OCDExportList", as you could imply from its name it allows you to export the List Definitions. OCDExportList is just STSADM extension which gives you list's schema xml . But, if you gonna use this schema xml in your feature deployment, you need to make some changes. By default "OCDExportList" exports list with all views, like "AllItems.aspx" and etc, but actually in 90% cases you need to use standard views, and don't deploy custom ones. So, to deploy list and use standard views the following changes of list schema xml should be applied
After that, the deployed list will use standard views Mirror: Export List Definition with OCDExportList and reusing standard Views May 08 Attend ReMIX 08 in Sydney - Experts standGoing to attend the ReMIX 08 in Sydney. You can catch me in "Expert Stand" section during breaks. April 25 Renaming server PC with SharepointUsually all Sharepoint development happens on virtual environment. There are several advantages of this, like
But when you are cloning your existed sharepoint system you end up with absolutely the same sever, including the same server name name. And this is the only problem. However, renaming server name with the installed Sharepoint is not trivial as you could expect. There are several items which should be renamed - server name, database name, Sharepoint references. And the situation became complex when your Sharepoint sites use Sharepoint Search - in this case you need rename MSSQL$MICROSOFT##SSEE database. Actually, I failed with renaming Sharepoint Search DB, and decided to turn search off before system renaming. The follow steps should be done to rename server with installed Sharepoint
That's all. Now you have the clone of your virtual server with the new server name. April 13 8 random factsLast 3 weeks were a bit tough, didn't have enough time to blog I moved back to the Sydney from long client engagement at Canberra government, had 2 short-term engagement in Sydney and was tagged by Mitch Denny regarding 8 random facts. So, it's my turn
Mirror: 8 random facts March 27 Protect your WiFi connectionsRecently start using the "Hotspot Shield" tool to protect the WiFi connections in public hotspots, which are usually affected by sidejackings. This tools provide the VPN connection between you and WiFi spot, protecting all your data. I use this tool all time when use the public hotspots during breakfast or lunch March 18 Sharepoint UserGroup (Canberra)Today I visited the Australian Sharepoint UserGroup in Canberra, and actually it was the first UG session which I liked (I visited UG in different countries and liked this one the most) Topic was about VSTO & Sharepoint. No Powerpoint, only live code :) The covered areas - WPF, Sharepoint, XSD, WebServices, VSTO Word Add-in and Ribbon customization. I really liked this sample. This session remembered me the first engagement in consultant role, where I did the similar task only for the Outlook plugin The presenter was Ishai Sagi - Sharepoint Microsoft MVP. Nice guy. He is blogging there http://www.sharepoint-tips.com/ PS: And I won the "Sharepoint Designer Step by Step" book :) Mirror: Sharepoint UserGroup (Canberra) March 15 Twitter map"Twitter Blocks" is a nice tool to build the map of your Twitter's neighbours Mine looks so http://explore.twitter.com/blocks/#laflour Mirror: Twitter map March 06 Era of pure software developers comes to an endIn last years I've started to note that there is no place for the pure developers in Computer Science world - their era comes to end. By "pure software developers" I mean those who speciality is just writing code and nothing else. I'd say I mean geeks. I'm not blaming them, because I consider myself being a geek a bit, but I reckon geeks are not valuable now as they were before - about 5 years ago. There are some changes happened in IT world. Looking around I found that IT became mature - we are not in infancy stage. We started to develop not for the sake of developing but for others. We are trying to automate the businesses, routines and we put software wherever it possible. It's hard to find the place where we don't use PC. We even finally started not the business for software, but software for business. Infancy has been ended. Now we need to think what to do with all that crap we created and how to resolve existed problems We are on the threshold to come on another level of abstractions, but we can't go further being on the same boat - we need paradigm shift. We need to be on the next level of maturity to solve current problems. Looking at the existed problems in all areas, like prediction systems, data mining, robotics end etc we see that everything is really good engineered - good architectures and good models, but it doesn't work as we expected, because we are missing the humane factor. I mean that existed Computer Science engineers can't solve existed problems, because they think in machine terms, losing the humanity. We |