Important notice

Please note that this blog is discontinued here. All the posts are also coppied to my new blog at http://boris.gomiunik.net.
Important: Due to large amount of comment spam further commenting has been disabled here. If you wish to send me a comment, plase look up the same post on my new blog and leave comment there. Thanks!

9/06/2007

Preloader image for ajax and similar web applications

I started to create my first ajax-like web application and I was looking a good site, where to find animated gifs.

After a while I've found a great site, which not only offers animates gifs, but actually you can generate the loader alone, selecting the foreground, background and style of the preloader.

Click here to get (generate) your preloader image.

8/17/2007

Resolving the "Unable to display this Web Part" problem after SharePoint Designer restore

If you've restored the SharePoint site using commands Site --> Administration --> Restore site and this site had special XSLT data views you may be in for a big surprise!

You can receive the following message:

Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Windows SharePoint Services-compatible HTML editor such as Microsoft Office SharePoint Designer. If the problem persists, contact your Web server administrator.

Or in Slovene language

Spletnega gradnika ni mogoče prikazati. Če želite odpraviti težavo, odprite spletno stran v urejevalniku HTML, združljivim s storitvami Windows SharePoint Services, kot je program Microsoft Office SharePoint Designer. Če težave ne morete odpraviti, se obrnite na skrbnika spletnega strežnika.

The problem is that while restoring the site, SharePoint designer doesn't correct the GUIDs of lists being used. For example: You're having an XSLT data view of a list called Contacts. When restoring SharePoint designer creates the list with a new GUID, but it uses the old GUID (from where the backup was made) of the list. The solution is simple: Fix the GUIDs of lists used in dataviews:

1. Open the Manage content administration page of your site (http://server/site/_layouts/mcontent.aspx)

2. Copy the shortcut of the list being used in XSLT to clipboard

3. In the URL you'll find the new GUID of a list between brackets ( in http://server/site/_layouts/ListEdit.aspx?List={89D731E5-0538-4999-B4AF-D7A5D9EA781F} the GUID is 89D731E5-0538-4999-B4AF-D7A5D9EA781F

4. With SharePoint Designer open the page with XSLT data view and search for term ListID in the code.

5. Select the value of the ListID parameter. It should be the GUID of the list (either in ListID="....." or in the same tag, look for GUID-like numbers.

6. Prest CTRL+H for Search and Replace with the value still selected. It will automatically populate the "Find what" field with it. Now paste the copied URL with GUID in the "Replace with" field and remove all but the GUID. Make sure you have the "Find in Source Code" option checked.

7. Now just press the "Replace all" button and your XSLT data view will magically come to life :).

I hope that this bug will be fixed with next version of SharePoint Designer, or maybe can develop some kind of plugin for that procedure to speed up the process for all the pages. I know that with FrontPage this wasn't happening.

8/14/2007

Access server different server with certain host name - build a new site while current still exists

The upgrade from Windows SharePoint Services 2.0 to 3.0 gave us in the company the opportunity to reconstruct some of the sites. The issue was that while the new site in WSS3 was in development, the site in the current server would stay active.

With version 2 this wouldn't be a problem. While having the existing www.site.com we'd create a new SharePoint site with the same host header and add a host header like new.site.com and work on it using new.site.com, while the DNS server is still pointing to the old site with www.site.com. At the end you just need to change dns for www.site.com.

The challenge comes with the version 3.0, because it's bound to host headers. Therefore it's best to work with the original host header from beginning. So how to build a website on a new server with a host header www.site.com while the other one still exists?

One alternative is already described in one of my previous posts.

The second alternative is to set up a DNS server to point to the new IP with the existing domain and use it like primary dns server on the development computer. Not practical - just to sacrifice the whole DNS server for one site.

My friend Miha - who in my oppinion should have a blog for all the great stuff that he advised me untill now - showed me even a better alternative. The third - best - alternative is that you trick your Windows XP or Windows Vista that www.site.com is on a certain IP - therefore server. Let's say for example that the existing site www.b4business.si is on IP 123.123.123.123. And the new server where we want to develop the site is on IP 123.123.123.321.

All we need to do is to edit the hosts file, which is located in c:\windows\system32\drivers\etc folder. At the end add the hostname (domain) and desired IP. - like in the picture below:

In Vista you have to have administrative rights to edit that file. After you've updated the hosts file, flush the DNS resolver cache (Start --> Run --> ipconfig /flushdns) and the the hosts file overrides any dns. Now you can edit the www.b4business.si on a new server.

When the site is ready, change the DNS to point to the new site and don't forget to remove the entry in hosts file.

Update: I've had the path to the file wrong. Now it's ok.

8/13/2007

Rearranged my blog homepage a bit...

It was a while from when I was checking what interesting gadgets blogger had to offer. Ofcourse checking them I was pleasantly surprised. So not so long ago using some new gadgets, I've rearranged my homepage a bit:

  • removed "About me" part
  • added "Read about" section with all my tags so you can filter
  • using a new feature in Blogger - added a small poll - which content you find most useful - you're invited to answer it so can get a feedback about what to write more. :) 
  • shuffled the right hand column a bit.

8/10/2007

fromURL - translate characters from URL

As mentioned in my previous post, you can pass parameters throught URL between pages. The problem can arise if you have special characters in parameters, like č, ž, š, spaces, etc. If you have the url

http://www.mysite.com/default.aspx?test=12 3

it will change to http://www.mysite.com/default.aspx?test=12%203 - so spacebar is converted to %20. And the function queryString would also get the value of parameter test to be 12%203. To complement the querystring you can use the fromUrl function that I've prepared, to translate these kind of characters:

 

function fromUrl(rezultat) { 
    rezultat = rezultat.replace(/%C4%8D/g,'č')
    rezultat = rezultat.replace(/%C4%8C/g,'Č')
    rezultat = rezultat.replace(/%C5%A1/g,'š')
    rezultat = rezultat.replace(/%C5%A0/g,'Š')
    rezultat = rezultat.replace(/%C5%BE/g,'ž')
    rezultat = rezultat.replace(/%C5%BD/g,'Ž')
    rezultat = rezultat.replace(/%22/g,'"')
    rezultat = rezultat.replace(/%20/g,' ')
    rezultat = rezultat.replace(/%23/g,'#')
    rezultat = rezultat.replace(/%25/g,'%')
 return rezultat
}

In the function above I've used the most common characters that need translation in slovene plus double quotation mark, spacebar, hash and percent sign. You can add more characters, I've prepared a table of characters and codes below. So now using a combination of these two functions

fromUrl(queryString('test')) would return the value 12 3.

Table of codes for URL encoding

Code Character   Code Character
%20 (space)   %C4%B8  ĸ 
%21 !   %C4%B9  Ĺ 
%22 "   %C4%BA  ĺ 
%23 #   %C4%BB  Ļ 
%24 $   %C4%BC  ļ 
%25 %   %C4%BD  Ľ 
%26 &   %C4%BE  ľ 
%27 '   %C4%BF  Ŀ 
%28 (   %C5%80  ŀ 
%29 )   %C5%81  Ł 
%2A *   %C5%82  ł 
%2B +   %C5%83  Ń 
%2C ,   %C5%84  ń 
%2D -   %C5%85  Ņ 
%2E .   %C5%86  ņ 
%2F /   %C5%87  Ň 
%C4%80  Ā    %C5%88  ň 
%C4%81  ā    %C5%89  ʼn 
%C4%82  Ă    %C5%8A  Ŋ 
%C4%83  ă    %C5%8B  ŋ 
%C4%84  Ą    %C5%8C  Ō 
%C4%85  ą    %C5%8D  ō 
%C4%86  Ć    %C5%8E  Ŏ 
%C4%87  ć    %C5%8F  ŏ 
%C4%88  Ĉ    %C5%90  Ő 
%C4%89  ĉ    %C5%91  ő 
%C4%8A  Ċ    %C5%92  Œ 
%C4%8B  ċ    %C5%93  œ 
%C4%8C  Č    %C5%94  Ŕ 
%C4%8D  č    %C5%95  ŕ 
%C4%8E  Ď    %C5%96  Ŗ 
%C4%8F  ď    %C5%97  ŗ 
%C4%90  Đ    %C5%98  Ř 
%C4%91  đ    %C5%99  ř 
%C4%92  Ē    %C5%9A  Ś 
%C4%93  ē    %C5%9B  ś 
%C4%94  Ĕ    %C5%9C  Ŝ 
%C4%95  ĕ    %C5%9D  ŝ 
%C4%96  Ė    %C5%9E  Ş 
%C4%97  ė    %C5%9F  ş 
%C4%98  Ę    %C5%A0  Š 
%C4%99  ę    %C5%A1  š 
%C4%9A  Ě    %C5%A2  Ţ 
%C4%9B  ě    %C5%A3  ţ 
%C4%9C  Ĝ    %C5%A4  Ť 
%C4%9D  ĝ    %C5%A5  ť 
%C4%9E  Ğ    %C5%A6  Ŧ 
%C4%9F  ğ    %C5%A7  ŧ 
%C4%A0  Ġ    %C5%A8  Ũ 
%C4%A1  ġ    %C5%A9  ũ 
%C4%A2  Ģ    %C5%AA  Ū 
%C4%A3  ģ    %C5%AB  ū 
%C4%A4  Ĥ    %C5%AC  Ŭ 
%C4%A5  ĥ    %C5%AD  ŭ 
%C4%A6  Ħ    %C5%AE  Ů 
%C4%A7  ħ    %C5%AF  ů 
%C4%A8  Ĩ    %C5%B0  Ű 
%C4%A9  ĩ    %C5%B1  ű 
%C4%AA  Ī    %C5%B2  Ų 
%C4%AB  ī    %C5%B3  ų 
%C4%AC  Ĭ    %C5%B4  Ŵ 
%C4%AD  ĭ    %C5%B5  ŵ 
%C4%AE  Į    %C5%B6  Ŷ 
%C4%AF  į    %C5%B7  ŷ 
%C4%B0  İ    %C5%B8  Ÿ 
%C4%B1  ı    %C5%B9  Ź 
%C4%B2  IJ    %C5%BA  ź 
%C4%B3  ij    %C5%BB  Ż 
%C4%B4  Ĵ    %C5%BC  ż 
%C4%B5  ĵ    %C5%BD  Ž 
%C4%B6  Ķ    %C5%BE  ž 
%C4%B7  ķ    %C5%BF  ſ 

Technorati tags: , ,

7/23/2007

QueryString - get parameters from URL with JavaScript

SharePoint passes a lot of information between pages with the aid of URL parameters. If you pay attention to the URL while watching the EditForm of some list, you'll probably find the folloring url:

http://server/site/lists/listname/EditForm.aspx?ID=1&Source=http://server/site/lists/listname/Allitems.aspx

The part after the question mark is important, since it's passing 2 parameters: ID with value of 1 and Source with value of http://server/site/lists/listname/Allitems.aspx.

Using XSLT with SharePoint Designer you can also get these parameters with XSLT's QueryString. But outside of a SharePoint Data View you can get the value of URL's parameters with the following script:

function queryString(parameter) { 
  var loc = location.search.substring(1, location.search.length);
  var param_value = false;

  var params = loc.split("&");
  for (i=0; i<params.length;i++) {
      param_name = params[i].substring(0,params[i].indexOf('='));
      if (param_name == parameter) {
          param_value = params[i].substring(params[i].indexOf('=')+1)
      }
  }
  if (param_value) {
      return param_value;
  }
  else {
      return false;
//Here determine return if no parameter is found
  }
}

So if I had my page http://www.mysite.com/default.aspx?test=123

The queryString('test') would return value 123.

This function is useful also outside of SharePoint. One word of caution though: Internet Explorer tends to translate a bit the urls, so spaces become %20 and similar. This can be solved with a simple function to translate these values. More about that - next time :)

7/17/2007

Refferencing SharePoint form fields with JavaScript

Sometimes you need to refference SharePoint form fields for manipulation. I usually use JavaScript. With SharePoint 2.0 you can refference a form field with

document.getElementsByName(urn:schemas-microsoft-com:office:office#Field_Name)[0]

where Field_Name is the SharePoint name of the field (you can find it at the end of URL when viewing properties of the field under "Modify Settings and columns". For example if I'd need to change the value of a form field Title, I'd use the following code:

document.getElementsByName('urn:schemas-microsoft-com:office:office#Title')[0].value = 'Boris'

Thus changing the value to Boris.

The story gets a bit more complicated with SharePoint 3.0. The names of fields now also contain ID of the form, which is constantly changing. The previous case in one of our forms would be

document.getElementsByName('ctl00$m$g_740df035_0c04_4906_89d7_cb38429413df$ctl00$ctl04$ctl00$ctl00$ctl00$ctl04$ctl00$ctl00$TextField')[0].value = 'Boris'

The problem occurs with changing ID of the form so you can't (at least that I know of) refference the form field value by name alone.

The solution here is using form titles. I've prepared a small javascript to get the form field by its type and title.

function getField(fieldType,fieldTitle) {
    var docTags = document.getElementsByTagName(fieldType);
    for (var i=0; i < docTags.length; i++) {
        if (docTags[i].title == fieldTitle) {
            return docTags[i]
        }
    }
}

Using this script now you can change the value of a title field with

getField('input','Title').value = 'Boris'

Page File on the server too high? Alternative to IISRESET

I've already been explaining in my previous post about application pools how to save on page file by reusing application pools.

When you need to release page file size and memory consumption, you can run iisreset. This will kill each application pool for each site and therefore release the memory (untill the site is revisited).

Joel Oleson is describing an alternative way to release the application pool and cache that we don't need without the 7-seconds-long iisreset. Below quoting from Joel's blog:

cscript c:\windows\system32\iisapp.vbs /a "%SharePointAppPool%" /r

Where %SharePointDefaultAppPool% is the app pool you are wanting to cycle.

7/09/2007

Unable to create SharePoint list from Excel (import spreadsheet)

If you're trying to import spreadsheet to create a SharePoint list in SharePoint 3.0 you can receive some errors. This especially occurs if you're using Excel 2003.

Thanks to Matjaž from Portorož, there is a resolution to this problem: update office 2003 to at least SP2 and the problem will go away.

7/07/2007

Another great .flv flash video player

In one of my previous posts I've already explained how to publish your own video on web pages (still a bit difficult in SharePoint blog :( because it gets filtered out). I've come across another very good .flv flash video player. It's published under creative commons licence and it's free for non.commercial use. What I also like about it is

Below is a sample video..
 

7/05/2007

SharePoint 3 is bound to host headers

With the old SharePoint we were using host headers much more freely. When the site was extended, all you needed to do is add additional host headers in the Internet Information Services console.

With SharePoint 3 the story is a bit different. When you create a site with host header through SharePoint Central Administration, that site is bound to the host header you created it with. This might cause problems with intranets (for example internal domain is one and external is other). Below is one solution (that I confess, I still have to try out) that might solve this problem:

Modifying ports and host headers on SharePoint

I also use the following trick: When the site is created, I go to the IIS administration console and add the desired host headers. Usually this will redirect to the original host header. Example: site is created with www.piflar.com, I've added also host header piflar.com. So when I visit http://piflar.com it automatically redirects to www.piflar.com.

The problem might occur with intranet sites. Internal domain can be http://companyweb2 and external http://intranet.company.com:444. If you visit the second url and redirects you to companyweb2 naturally you won't be able to open the site.  

The solution can be that you add the default.aspx after the url. So if you visit http://intranet.company.com:444/default.aspx you won't get redirected and you can see the SharePoint.