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!

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.

6/20/2007

Remote desktop from Windows Vista slow or not working?

I use a lot of remote desktop to manage access to clients or servers. But after installing Windows Vista on my computer, this has been virtually impossible. When I tried to remotely connect it got the connection, but it slowed down or completely froze so it wasn't possible to even log on.

Finally I've found a solution for the slow remote desktop problem here.

It was needed to run the command prompt as administrator and disable auto tuning for the TCP/IP receive window. If you're having the same problem use command

netsh interface tcp set global autotuninglevel=disabled

To reenable it enter

netsh interface tcp set global autotuninglevel=normal

And remote desktop magically started working!

6/11/2007

Reinstalling SharePoint (WSS3) to run under SQL server 2005 instead of Windows internal database (##SSEE)

Recently I was fixing on one server an installation of Windows SharePoint Services that has gone wrong. Even though we've had SQL server 2005 installed correctly, WSS3 installed its own Windows internal database (##SSEE) and started using it. I thouhght a simple uninstall and reinstall of WSS would do the trick. But it didn't. After uninstalling and trying to reinstall WSS3 at the beginning didn't even offer the option to configure it to SQL server (the step in WSS configuration where is asking you which is the location of configuration database,...).

After a couple of retries (also uninstalling SSEE and a lot of reading on the web to my horror I've found one sentence "you'll need a clean install of Windows Server 2003."

.

This was a bit tough because of existing users and some other parameters. After digging a bit deeper and combining knowlege of couple of experts' blogs I've managed to successfully reinstall WSS3 without Windows Internal Database (SSEE) and into SQL server 2005.

Before I write how I did it, let me clear that this solution worked for me. I'm presuming that you don't have anything else installed in SSEE and I'm not responsible for any errors that might happen if you're following the same procedure. So please before making anything on a production server - backup, backup, backup. This procedure includes messing with Windows registry!

Here goes:

1. Copy all the SharePoint Sites to another temporary folder
Using
 
stsadm -o backup -url http://<site_collection_url> -filename <location and filename>

 
copying backup files to new server and
 
stsadm -o restore -url http://<site_collection_url> -filename <location and filename>

 
on the temporary server worked the best. It kept all the relations and all the custom formatting on all the sites.

2. If these are productions sites modify DNS or forwarding to point to the temporary server

3. Here's where the "fun" begins: Delete all the SharePoint Web applications

4. Uninstall Windows SharePoint Services through Control Panel

5. Uninstall Windows internal database (##SSEE)
Connex' Copper Coins has it described in his blog here. Just in case I'm writing a short ressume:

Under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall click different GUIDs untill in the right pane you see under "Display name" Microsoft SQL 2005 Embedded Edition". Under that registry copy the value under "UninstallString". Run the command prompt window, paste the command AND add "CALLERID=OCSETUP" at the end of commend line. For example: MsiExec.exe /X{BDD79957-5801-4A2D-B09E-852E7FA64D01} CALLERID=OCSETUP.EXE.

(ressumed from Connex' Copper Coins)

6- Delete all files and folders under %windir%\SYSMSI\SSEE

7. delete all and folders files under %Programfiles%\Common Files\Microsoft Shared\web server extensions\12

8. Using reged backup and delete in registry everything under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0\

9. The previous step also deleted the "Server language" entry. so Using notepad create a .reg file with the following text:

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0\ServerLanguage]
"1033"=""

and run it to restore the "Server Language" entry needed for Windows SharePoint Services installation.

With that I have removed every trace (or at least enough) of Windows SharePoint Services 3.0 from the server. Now I was able to re-run the WSS 3 setup and and it offered me the option for nstalling it into SQL server 2005 and without SSEE.

This is how you can have it done without making a clean install of Windows Server 2003.


If you need help installing WSS, I recommend the following article on technet:

http://technet2.microsoft.com/windowsserver/WSS/en/library/6181fe5b-90ca-40cf-aade-abd59cf3c9071033.mspx?mfr=true

6/06/2007

Windows Live Writer Beta 2 available

I'm already using it to write all my posts for this blog. It has many improvements and features, so I recommend it. Amongst many others, one of them is also the support for blogger tags. You can download it from Windows Live writer website, but the link is misleading. Don't click on the big Download button, because it will lead you to the Live Betas web page.

 To download Windows Live writer, click on the links in the left bar. Click here to go to Windows Live Writer

Click here to go to the page and download Windows Live Writer beta 2

More options for creating a favicon

In my past post about creating favicon online nicolas sent me a comment with a link to another good tool for creating favicons. It's a favicon generator from images. All you need to do is to upload 16x16 or 32x32 .gif or .png file and it will generate the favicon for you. You can find this tool on Web Script lab.

.

If you have Paint.net, you can also download a plugin that will save your image like a favicon - so you can make your favicon also offline.

There are many options also online if you don't want to make your favicon. One is to search for them. I've also found one favicon gallery.

 

All this talk about favicon. And how to insert the favicon? If you have a favicon file named favicon.ico in the same folder that the web page you're trying to add it to, in the head if the page add the following line of code:

<link REL="SHORTCUT ICON" href="favicon.ico" type="image/x-icon">

6/04/2007

Application pool for each SharePoint (WSS) site?

After a long time I'm returning with some SharePoint administration and deployment topics.

One of them is Web application pools with SharePoint. When creating more top level sites with each its own application pool, you can seriously think about how this will affect the server performance.

With around 50 SharePoint sites (and app pools) running we've increased the page file from 1 GB to almost 4 GB.

So planning here is very important. Think about how many web applications you'll need. If you'll need many, think about grouping web applications to application pools.

The difference in performance is very obvious.

If anyone has similar experience, I'll be more than happy to read about it in the comments to this post. :)

5/04/2007

"Cannot connect to the configuration database" and SharePoint

Today I've received another of the cases when SharePoint (v2) couldn't connect to the configuration database. This can be a common problem but it's not so horrible to solve it.

The reason for this is that SharePoint lost the connection to the database.

Reasons may be the following:

  • SQL or WMSDE database may not be running

  • IIS may be running in IIS 5.0 isolation mode
  • The account for connecting to SQL or WMSDE might be gone or with changed password
  • update - SQL Server Embedded Edition might not be running (check services) - Thanks, deanoc (see the comments)

The solution to these is on the following link:

http://support.microsoft.com/kb/823287/en-us

But I've found another reason that could be. Simple: The SQL is running, credentials are also ok and IIS isn't in the 5.0 isolation mode. The problem may occur if sharepoint simply can't find the database. Reasons for this may be many: the database has moved, dns has changed, ... In my case was the later. By changing the DNS server in the network we've had to add one more record manually to point to the correct one and the sites started to work.

4/16/2007

Windows Vista and Flash problem

Even though I've had Flash player installed in my Windows Vista, there was a funny error. In some cases I could see the flash videos and in some cases no (like on SoapBox or YouTube. I've found the solution to the problem.

Below is the recording on how to fix the problem. 


Video: How to fix Flash problem in Windows Vista

4/08/2007

Create favicon online

Usually for websites we just have to create the favicon only once. So it's a bit of unuseful to download and install extra software for this (even though we can make the icons with paint.net)

For one time ocasion you can draw or create the icon from an image file online. Here's an online icon-maker.

4/03/2007

NT Conference is coming!

The biggest IT event in Slovenia is coming! In our company we're going to have an unofficial blog about it. Below is the first video



Video: NTK Video Series v1.0

3/24/2007

A good starting point for creating web designs

A w3c recommendation is that for website layouts and design layers should be used instead of tables. In lots of WYSIWYG HTML editors you don't get the built-in functionality to easily create layout with layers.

So I've found a very good starting place for creating a website. It's a set of "wireframes" from which to build your web page layout.

They're using XHTML and CSS.

Click here to visit the site and get the CSS templates.