We had a site that did not show the borders around a div in IE6,
After a while (and using google) I found out that I only needed to add
position: relative; on the element or its ancestors (only that element and descendants are fixed)
I found it Here.
Thursday, October 8, 2009
Tuesday, October 6, 2009
Good old VB functions in c# Left, Mid, Right
Missing the good old string functions in c# I wanted to recreate them.
This is my solution where they are resurrected as extension methods.
To keep the code from giving errors I check for the length parameter,
if this is not what you want, you can throw an argumentexception for example ...
This is my solution where they are resurrected as extension methods.
public static class StringHelper
{
public static string Right(this String source, int length)
{
if (source.Length == 0 || length <= 0)
{
return "";
}
return source.Substring(source.Length - length, length);
}
public static string Left(this String source, int length)
{
if (source.Length == 0 || length <= 0)
{
return "";
}
return source.Substring(0, length);
}
public static string Mid(this string source, int startIndex, int length)
{
if (source.Length == 0 || length <= 0 || startIndex < 0)
{
return "";
}
return source.Substring(startIndex, length);
}
public static string Mid(this string source, int startIndex)
{
if (source.Length == 0 || startIndex < 0)
{
return "";
}
return source.Substring(startIndex);
}
}
To keep the code from giving errors I check for the length parameter,
if this is not what you want, you can throw an argumentexception for example ...
Labels:
c#,
extension methods,
string manipulation,
visual basic
Thursday, July 2, 2009
Javascipt Replace, Replace All
Working in javascript today,
I found out that in javascript, the replace function only replaces the first occurrence, not all as in c#/VB.
You can test this by pasting the following in the addressbar of (most) browsers:
javascript:alert('test-test-test'.replace('-',''));
To replace all occurrences you need to use regular expression (place the word you want to find between / /g :
javascript:alert('test-test-test'.replace(/-/g,''));
or you can create a javascript function eg:
function replaceAll(text, findText, replaceText)
{
return text.replace( new RegExp(findText,"g"), replaceText);
}
I found out that in javascript, the replace function only replaces the first occurrence, not all as in c#/VB.
You can test this by pasting the following in the addressbar of (most) browsers:
javascript:alert('test-test-test'.replace('-',''));
To replace all occurrences you need to use regular expression (place the word you want to find between / /g :
javascript:alert('test-test-test'.replace(/-/g,''));
or you can create a javascript function eg:
function replaceAll(text, findText, replaceText)
{
return text.replace( new RegExp(findText,"g"), replaceText);
}
Friday, March 6, 2009
Portable Browsers
Are you a webdeveloper,
or do you need to run some sites in a specific version of Internet Explorer (or Firefox or ... )
Or do you just want to try a new browser version without installing it?
Earlier I put up an article about IETester which allows you to run Internet Explorer 6 (and others) on Vista.
Now I found a new (and better) way to run different browsers without the need for installation :
http://www.xenocode.com/browsers/
Currently they have the following browsers :
- Internet Explorer 8, 7, 6
- Firefox 3, 2
- Google Chrome
- Opera
- Safari
From the site :
So they should run on any version of windows (not yet tested, only on vista).
Have fun!
It works fine here, and I have
or do you need to run some sites in a specific version of Internet Explorer (or Firefox or ... )
Or do you just want to try a new browser version without installing it?
Earlier I put up an article about IETester which allows you to run Internet Explorer 6 (and others) on Vista.
Now I found a new (and better) way to run different browsers without the need for installation :
http://www.xenocode.com/browsers/
Currently they have the following browsers :
- Internet Explorer 8, 7, 6
- Firefox 3, 2
- Google Chrome
- Opera
- Safari
From the site :
Xenocode WebApps do not require any software to be installed and allow multiple application versions to run side-by-side on any version of Windows.
So they should run on any version of windows (not yet tested, only on vista).
Have fun!
It works fine here, and I have
Wednesday, February 25, 2009
Menu Selection Gets Stuck on Screen
At work,
when I chose an item in a right click menu it stuck on screen,
It dissappeared when I locked and then unlocked the pc,
but reappeared the next time I selected an item. This does not work in windows 7 (and maybe 8), the quick workaround there is Start > Run :
Right clicking the desktop and closing the menu also helped, but this were only workarounds.
I finally solved it :
Go into Windows Performance Options and de-select the option for "Fade out menu items after clicking."
In Vista, you can find it by right clicking My Computer > Properties > Advanced system settings (link on the left) > Advanced (tab) > Performance settings (button) > Visual effects (tab).
To cure it one in windows 7 you can set the corresponding monitor from 32 bit to 16 bit and back again, to remove one item. If it keeps happening, use the above solution.
when I chose an item in a right click menu it stuck on screen,
It dissappeared when I locked and then unlocked the pc,
but reappeared the next time I selected an item. This does not work in windows 7 (and maybe 8), the quick workaround there is Start > Run :
tskill dwm
Right clicking the desktop and closing the menu also helped, but this were only workarounds.
I finally solved it :
Go into Windows Performance Options and de-select the option for "Fade out menu items after clicking."
In Vista, you can find it by right clicking My Computer > Properties > Advanced system settings (link on the left) > Advanced (tab) > Performance settings (button) > Visual effects (tab).
To cure it one in windows 7 you can set the corresponding monitor from 32 bit to 16 bit and back again, to remove one item. If it keeps happening, use the above solution.
Friday, February 20, 2009
Windows Needs to Format this device when you plug in usb stick
I recently bought myself a Sandisk Cruzer stick for on the road.
Everything worked fine untill windows (vista) began to complain when I plugged in the stick : Windows needs to format this device (or something very similar)
Having some data on the stick I didn't want to format it, so I started looking around. I found the solution :
With the usb stick plugged in (it does not really matter but it makes it easier)
go to Start / Control Panel
Here depending on whether you have the classic view or not :
Classic view : System / Device manager (left side)
Standard view : Hardware and Sound / Device manager / View hardware and devices
Here find the usb stick driver in the device manager (should be under Disk Drives),
be sure to select the correct one!
Right click it and choose uninstall
After this unplug and replug the usb stick, vista will now install 'new' drivers and that did the trick for me.
I also read somebody who had to redo this when he restarted vista, but in my case this was not needed.
Everything worked fine untill windows (vista) began to complain when I plugged in the stick : Windows needs to format this device (or something very similar)
Having some data on the stick I didn't want to format it, so I started looking around. I found the solution :
With the usb stick plugged in (it does not really matter but it makes it easier)
go to Start / Control Panel
Here depending on whether you have the classic view or not :
Classic view : System / Device manager (left side)
Standard view : Hardware and Sound / Device manager / View hardware and devices
Here find the usb stick driver in the device manager (should be under Disk Drives),
be sure to select the correct one!
Right click it and choose uninstall
After this unplug and replug the usb stick, vista will now install 'new' drivers and that did the trick for me.
I also read somebody who had to redo this when he restarted vista, but in my case this was not needed.
Tuesday, January 13, 2009
Run as different user in Vista and Server 2008
When you shift + right click in Vista (or Server 2008) you will not find the trusted Run As ... Item, all you find is Run as Administrator. But this is not always what you need.
You can use the command prompt and the Runas command but this is not so easy as the old right click command.
Enter Sysinternals, they release a little tool called ShellRunAs that you can find here
After you downloaded it copy the ShellRunas executable to the windows\system32 folder and run shellrunas /reg
From this moment the run as different user item is back in your rightclick menu (or in your shift right click menu)
Thanks Sysinternals!
You can use the command prompt and the Runas command but this is not so easy as the old right click command.
Enter Sysinternals, they release a little tool called ShellRunAs that you can find here
After you downloaded it copy the ShellRunas executable to the windows\system32 folder and run shellrunas /reg
From this moment the run as different user item is back in your rightclick menu (or in your shift right click menu)
Thanks Sysinternals!
Subscribe to:
Posts (Atom)