Category Archives: Uncategorized

Thoughts on SPC14

LV2_0001

So I attended the official SharePoint Conference in Las Vegas for the first time last week, and after a few days of contemplation I just want to try and summarize the experience and try to jot down some of the takeaways.

For an even better summary, check out my Colleague Anatoly’s summary over at Chuvash. =)

And while a lot of this may not be news, it’s still the impression I got from the conference. If it’s old news, it might just be a more clear sign that this is indeed the path Microsoft is on when it comes to SharePoint.

SharePoint and Office

So it’s been back and forth with SharePoint and Office since… well like forever. SP 2007 was called MOSS (Microsoft Office SharePoint Server), but then they removed SharePoint as a part of Office in 2010. Now they’re bringing it back, but of course (unless you haven’t noticed yet) as a part of the online version, Office 365 and SharePoint Online. Microsoft is (and this is not new for 2014) betting big on Office 365, and they aim to have SharePoint Online usage exceed SharePoint on premise usage by 2016. I won’t go in to a discussion on why you should or shouldn’t migrate to SharePoint Online, but it’s pretty clear what the Microsoft roadmap looks like. This was extremely obvious during the conference as the word SharePoint hardly appeared without an Office logo next to it, and many sessions were focused to SharePoint AND Office developers. The question is how well (or rather how fast) the SP community and businesses will accept and adopt it. What I do believe is no matter what you may feel about SharePoint Online and Office 365, everyone planning on using or developing SharePoint in the future have better to start learning the differences, and preparing on what a migration might require in the future. That said, there is still a lot happening with the platform, and it will probably have a lot less gaps in it in a year or two, as updates are pretty frequent.

App-solutely! (Oh no he didn’t!)

Bad jokes aside, the (SharePoint) Cloud App Model won’t just be a fluke, passing by if we just keep ignoring it. I know that a lot of developers (including myself) often get stuck on it’s flaws, and argue against using it in favor of our dear old sandboxed and farm solutions. But the planet of the apps is coming, and it’s not Microsofts “fault”. It’s just their version of a shift taking place in the entire space of web and application development. One of the main reasons (I think) for us developers having such trouble adopting it, is due to the fact that we once again have to handle a lot of things that were previously handled for us, like passing authentication tokens across domains and other tedious tasks. In short, it’s more difficult to develop some things using the App Model than using a good old visual webpart for example. But we need to learn how to do it, anyway. It’s not our choice, it’s not Microsofts choice (sort of). It’s just how it is.

AND… The App Model is still pretty new compared to “the good old stuff”, and it’s evolving all the time, as is the body of knowledge possessed by the SP community. It will get better, and easier to work with. For now, we just have to keep improving ourselves and learn all the new techniques and skills needed to be good little SP developers.

SharePoint is getting smaller

So we’ve seen it before. In SP 2013, a few services were cut loose, the recommendation to host them on individual servers. For example Office Web Apps (I know it was a separate product even in SP2010), Workflow Manager or Foundation or what’s it’s name, etc. This goes hand in hand with the architectural mindset of the App Model, and what’s happening in Office 365. Instead of having SharePoint as a big, bulky blob of a system slash platform slash product slash everything, Microsoft is taking the approach of detaching components from one another, having the possibility to connect them to each other instead. While this will require more configuration than before (just look at the Workflow engine), it provides a better architecture, providing better performance, stability, maintainability etc.

Side note: Developers can adopt this same mindset when building functions for their SharePoint portals, using the App Model. Building a function which runs separate from SharePoint, but is still used from within has a lot of benefits, and will go hand in hand with the path Microsoft is taking. So the next time you’re considering making yet another Visual WebPart, just give a few minutes of thought if it might not be better to build it as an app (and add about 500 % of development time to your project plan for learning how to build it, host it and use it).

SharePoint 2015

Yes there will be another SP on premises released in 2015. Will give us some more time to adapt to O365. Yay!

SharePoint Dev = Web Dev

Being a good SharePoint developer is more and more becoming being a good Web developer. While scary for some, it’s not a bad thing. It means that we may benefit from a larger developer community, with all the benefits it brings. Plus, being a web developer is cool. Like… hipster cool (or?).

Microsoft is also getting better at using standards and open source stuff regularly used by the web community. What about an Office 365 SDK for android on GitHub? And sessions this year have even promoted using javascript frameworks such as AngularJS developed by Google. I think our little boy is finally growing up. =)

Conference available for all

So the entire conferences sessions (I think) will be available on Channel 9 for all to see, both videos and presentations. While some (douchebags) whine about spending $$$ plenty on actually attending the conference needlessly, I say HORAY! Knowledge should be free. I like the sharing Microsoft better. =)

Here is a short list of sessions I attended which I think were awesome, or simply informative.

  • Developer audience keynote | What’s new for the Office & SharePoint developer (If you want to see what Microsoft wants)
  • SharePoint Power Hour – New developer APIs and features for Apps for SharePoint
  • Adjust the perspective with responsive designs for SharePoint
  • Build your own REST service with WebAPI 2
  • Apps, BCS, OData, Search and O365…Oh My
  • Site provisioning techniques with SharePoint apps
  • Deep dive: REST and CSOM comparison
  • Best practices for maintaining and updating a SharePoint App

LV1_0038

How to provision a ContentEditorWebPart (CEWP) with predefined content to a page using a module

I did this a long time ago, then when I recently had to do it again, I couldn’t fid any Resources online describing how to do it. Simply adding text to the <Content> tags of the <AllUsersWebPart> declaration didn’t do it. The reason is simple I Think. The content in a CEWP is html, and you need encoded HTML tags for it to show. Otherwise the content will simply be ignored (This is my own theory at least. I haven’t investigated much).

So knowing that you can add any html content. Here is how you add an image for example:

<Content xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor"> 
    ​&lt;img alt=&quot;&quot; src=&quot;/PublishingImages/image-sample.png&quot;&gt;
</Content>

The easiest way to get encoded HTML is to use an Encoder, like this one. Simply paste your html and press encode. Then paste the results inside the <Content> tag for the CEWP. My full code example can be found below. This is to be put inside the File element in a Module:

<AllUsersWebPart WebPartZoneID="Right" WebPartOrder="1">
        <![CDATA[
           <?xml version="1.0" encoding="utf-8"?>
            <WebPart xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/WebPart/v2">
              <Title>MyTitle</Title>
              <FrameType>None</FrameType>
              <Description>MyDescription</Description>
              <IsIncluded>true</IsIncluded>
              <ZoneID>Right</ZoneID>
              <PartOrder>4</PartOrder>
              <FrameState>Normal</FrameState>
              <Height />
              <Width />
              <AllowRemove>true</AllowRemove>
              <AllowZoneChange>true</AllowZoneChange>
              <AllowMinimize>true</AllowMinimize>
              <AllowConnect>true</AllowConnect>
              <AllowEdit>true</AllowEdit>
              <AllowHide>true</AllowHide>
              <IsVisible>true</IsVisible>
              <DetailLink />
              <HelpLink />
              <HelpMode>Modeless</HelpMode>
              <Dir>Default</Dir>
              <PartImageSmall />
              <MissingAssembly>Det går inte att importera den här webbdelen.</MissingAssembly>
              <PartImageLarge>/_layouts/images/mscontl.gif</PartImageLarge>
              <IsIncludedFilter />
              <Assembly>Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
              <TypeName>Microsoft.SharePoint.WebPartPages.ContentEditorWebPart</TypeName>
              <ContentLink xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
              <Content xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor"> 
                ​&lt;img alt=&quot;&quot; src=&quot;/PublishingImages/image-sample.png&quot;&gt;
              </Content>
              <PartStorage xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
              </WebPart>
              ]]>

This works in SP2010 and 2013. Just change the assembly version to 14 or 15 depending on which you are using. I presume it works the same in 2007 also, but I haven’t tried.

Get and format DateTime string from SharePoint DateTime field

A collegue of mine (his blog here) showed me something nice yesterday. We have a webpart which shows how long ago some list items where created by simply getting the DateTime string from the standard “Created” column.

string x = ((DateTime)item[SPBuiltInFieldId.Created]).ToString();

We ran into trouble however, when we used this webpart on a server in a country using a different time format. The problem was easily fixed like so:

string x = ((DateTime)item[SPBuiltInFieldId.Created]).ToString(“s”);

This converts the DateTime string to a standard format which allows it to be understood by various javascript and jQuery functions and plugins, which was exactly what we needed.

Here is a list of other formats you can get with this method by simply replacing the “s” with another letter.

Increase disk space for a VMWare virtual machine

I had a virtual machine which had about 40gig of hard drive space, and I needed to add another 20. At first I thought this would be supported by VMPlayer, but as I found out, it wasn’t. If you have VMWorkstation you will have access to a tool called vmware-vdiskmanager which is able to do just that, but since I didn’t, I had to find another solution. Thankfully, one of my colleagues had a great solution using Ubuntu.

Yes Ubuntu is an operating system. NO YOU DON’T HAVE TO INSTALL ANYTHING, not even Ubuntu! I know it seems like there are a lot of steps, but that’s just because i’ve broken them down into very small ones to make it easier. It is really not a lot of work.

NOTE!
I personally didn’t run into any issues when doing this, and my virtual machine worked fine afterwards. But since it is a delicate operation, you should really make a copy of your virtual machine before trying this.

Firstly, you have to expand the amount of disk space the virtual machine is allowed to use. This is done directly in VMPlayer when the virtual machine is shut down.

  1. Open VMPlayer
  2. Click on the virtual machine who’s hard drive you want to expand.
  3. Click on Edit virtual machine settings
  4. On the hardware tab, click on the Hard Disk in the device list. On the right hand site a Utilities drop down will appear, click it and select Expand.

NOTE:
One might think that this should be enough, and that the disk space of your virtual machine would magically expand to the set amount, but this is not the way it is. It’s not strange really if you consider a virtual machines hard drive being composed by partitions, just like a regular computer. When you expand the disk space, you simply give the virtual machine more disk space, you don’t increase the space for already existing partitions, which is not strange at all. To do this, as I said earlier, you need another tool. I’m sure there are plenty of working tools out there, and some may be easier to work with than this, but for me doing it with Ubuntu worked great.

 The second thing you need to do is increasing the space for the already existing hard drive partition within your virtual machine. You can do this by following these steps:

  1. Download Ubuntu and save the iso-file to the hard drive on your regular computer (not the virtual machine).
  2. Start your virtual machine. From the top menu bar, click Virtual Machine -> Removable Devices -> CD/DVD(IDE) -> Settings. This will open a settings dialog.
  3. On the hardware tab, click CD/DVD (IDE) in the device list.
  4. Under the Connection area, click Use ISO image file and then browse. Browse to the location of the Ubuntu ISO and open it.
  5. When the Ubuntu ISO is selected, just click OK to save and close the Settings dialog. The ISO should now be mounted and readable as a DVD from within the virtual machine.NOTE:
    Ubuntu let’s you start a demo version of the OS without installing anything. All you need to do is boot the machine using the mounted ISO. This is quite amazing if you ask me. But then again I’m not very proficient with these kinds of things.Now you need to restart your virtual machine and boot it from the mounted image. This can be a bit tricky, because you need to change the settings in the BIOS, and you hardly have any time at all to enter bios during the booting sequence.
  6. Restart the virtual machine. When it says Shutting Down, start spamming F2 (press the button repeatedly). You have like a 0,5 second window during which you have to press the button, so just pressing it worked best for me.
  7. Once you’ve entered the BIOS, go to the Boot tab and change the order of the devices so the CD-ROM Drive is positioned above the Hard Drive.
  8. Save and exit the bios (F10).The virtual machine should now boot using the mounted image, and you should come straight into the Ubuntu operating system.Note
    I had a bit of trouble while inside Ubuntu. The graphics of my mouse pointer did not appear in the same location as the actual mouse pointer, so I had a hard time clicking the right buttons. This was manageable using keyboard commands and clicking with the mouse randomly to see it’s current position.
  9. When the first screen appears, choose Try Ubuntu, don’t install it.
  10. From within Ubuntu, press the windows key on your keyboard to open a search panel. Type “gparted” and an icon for the GParted Partition Editor will appear. Press the arrow down key until you’ve selected the GParted icon and then press enter.
  11. You should now see a list of Hard drive partitions and a graphical representation of these. You can increase the size of the partition by selecting it in the list (a bit tricky if you have the mouse problem explained earlier), click the partition tab in the menubar, and then press Resize/Move.
  12.  Increase the value of the New Size to the Maximum size and press Resize/Move. A new pending operation should be created and displayed at the bottom of the screen. Click
  13. Click the Apply all operations button from the Edit tab in the menu bar.
  14. Wait until completed.
  15. To restart the computer click the windows key. Just type “terminal”, press the  arrow down key until you’ve selected the terminal icon and press enter.
  16. In the terminal window, type “sudo reboot” and press enter. Don’t forget to enter bios again when the machine restarts by pressing F2, and changing the bios settings to boot using the hard drive.

And that should be it. Worked for me at least.

Get Ubuntu here. It is a free open source operating system.

If you have VMWorkstation you should already have a tool for doing this. You can read how to here.

Cross-browser CSS Gradient

CSS gradient that works in IE8, IE9, FF and Chrome (dunno which versions).

Just add the following lines to your css class.

filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0090DB', endColorstr='#027DC0'); /* for IE */
background: -webkit-gradient(linear, left top, left bottom, from(#0090DB), to(#027DC0)); /* for webkit browsers */
background: -moz-linear-gradient(top,  #0090DB,  #027DC0); /* for firefox 3.6+ */

For more information and better examples, just follow the link below.

Found it here.

Add SharePoint notification message after postback

This method can be called from codebehind to show a sharepoint notification after the page postbacks. It will add a literal control to the page which contains the code for the notification. The literal will only be written after a postback. If the page is reloade through a redirect or similar the notification will not be shown.

public static void ShowNotificationOnPage(Page page, string text)
{
 StringBuilder stringBuilder = new StringBuilder();
 stringBuilder.AppendLine("<script>");
 stringBuilder.AppendLine("ExecuteOrDelayUntilScriptLoaded(ShowNotification, \"sp.js\");");
 stringBuilder.AppendLine("function ShowNotification()");
 stringBuilder.AppendLine("{");
 stringBuilder.AppendLine(string.Format("SP.UI.Notify.addNotification(\"{0}\");", text));
 stringBuilder.AppendLine("}");
 stringBuilder.AppendLine("</script>");
 page.Controls.Add(new LiteralControl(stringBuilder.ToString()));
}
 Soure here.

A place for knowledge and experiences

I intend to use this blog as a place to gather the knowledge and the experiences I aquire during the course of my work as a SharePoint developer. It will not only contain posts about SharePoint however, but also posts about related subjects such as server configuration, .NET, web programming and more.

The blog is solely created for my own use. But if someone were to benefit from it, all the better.