Thursday, February 19, 2009

Ignore query in jQuery treeview persist location

The jQuery treeview plugin can be found here, it is a brilliant plugin which makes amazing treeviews.

But when i use:

persist: "location"

 I run into a little "problem", because i would like to have the treeview item selected when i use query's in the URL, and as default it just doesn't select any when using query.

What I need to do is to detect if there is a query in the url and then ignore it, I've done it the following way:

case "location":

var current = this.find("a").filter(function()
    return this.href.substring(0, (this.href.indexOf("?") == -1) ? this.href.length: this.href.indexOf("?")).toLowerCase() == location.href.substring(0, (location.href.indexOf("?") == -1) ? location.href.length: location.href.indexOf("?")).toLowerCase();

It is a pretty simple fix and works like a charm!



This version is also able to handle bookmarks and query in url.

case "location":

var current = this.find("a").filter(function()
    var linkLength = (this.href.indexOf("?") != -1) ? this.href.indexOf("?") : (this.href.indexOf("#") != -1) ? this.href.indexOf("#") : this.href.length;
    var link = this.href.substring(0, linkLength);

    var urlLength = (location.href.indexOf("?") != -1) ? location.href.indexOf("?") : (location.href.indexOf("#") != -1) ? location.href.indexOf("#") : location.href.length;
    var url = location.href.substring(0, urlLength);

    return link.toLowerCase() == url.toLowerCase();

Wednesday, February 18, 2009

Windows remote desktop security

I've been wondering about how secure Windows Remote Desktop actually is, and it seems like you can be pretty protected with some common sense and few changes.
Here are a few tips that I have found while searching:
  • As default all administrators has remote desktop access, so it is a good idea to change the Administrator users name to a different name.

    1. It is found in: Control Panel -> Administrative Tools -> Local Security Policy -> Local Policies -> Security Options
    2. Find: "Accounts: Rename administrator account" in the list, and right click and Properties.
    3. You are able to rename the administrator name here, and then restart the computer.
    4. While your in the Local Policies you can change the values in the Account Policies to be as you want it, like changing the: Account lockout threshold to a few attempts.
  • Another thing is to change the default port number of remote desktop which is 3389, it can be changed the following way.
    1. Go to: Start -> Run -> write "regedit" -> press OK.
    2. Go to the following folder: HKEY_LOCAL_MACHINE -> System -> CurrentControlSet -> Control -> TerminalServer -> WinStations -> RDP-Tcp
    3. Find: "PortNumber" in the list, and right click and "Modify..."
    4. Write your desired port number and remember to add ":PortNumber" at the end of the URL when connecting to your Remote Desktop, and be sure to check if the firewall port is open.

Saturday, February 14, 2009

Convert your Windows Server 2008 to a Workstation

I use windows server 2008 as a workstation myself, and there are significant changes which can be made to make it much better as a workstation.
A great site that i used to reconfigure mine is:, there is guides to everything, from disabling the shutdown tracker to performance increases and much more!
..i can warmly recommend it, because it gives a better workstation experience on a awesome OS.

Friday, February 13, 2009

Saving changes is not permitted in Microsoft SQL Server Management Studio 2008

If you try to change columns in a table that you've created you will get the following message:

"Saving changes ins not permitted. The changes you have made require the following table to be dropped and re-created. You have either made changes to a table that can't be re-created or enabled the option Prevent saving changes that require the table to be re-created.". I think this option isen't very useful as enabled by default.

The message explains itsel, you have to disable the "Prevent saving changesthat require the table to be re-created", but where is this option.
Tools -> Options -> Table and Database Designers -> Uncheck "Prevent saving changes that require the table to be re-created"

Sunday, February 8, 2009

Aviary editors is worth trying

My friend said I should check this link, and so i did:

I looked at it and found a lot of pretty cool "editors" or as they say it: "creation accessible to artists of all genres, from graphic design to audio editing.".

I don't like flash very much, but i must say it is the best browser based photo editor I've ever seen, and properly also the only one ;)

I haven't checked out the others that much, but I'm sure they are just as nice. So if you need a photo editor on the fly i would recommend the one Aviary Phoenix Image Editor.

Friday, February 6, 2009

Request file from javascript created file uploads

If you want the files from your file uploads you normally use:


But when the file uploads is created using javascript like so:

var element = document.getElementById("ctl00_ContentPlaceHolder1_DdlFileCount");

var Value = element[element.selectedIndex].value;

var container = document.getElementById("TextboxContainer");

container.innerHTML = "";

for (var i = 0; i < Value; i++) {

    container.innerHTML += "<input class='textbox' type='file' name='FileUpl" + i + "' id='FileUpl" + i + "' /><br />";


The Request.Files won't detect the files uploaded by the client using the dynamic file upload.

The reason why, is because at compile time creates an Enctype in the form, this wont get created when client-side scripting is doing the creating of control.

My friend found a pretty simple solution, where you just need to add the following line to your page load event:

Form.Enctype = "multipart/form-data";

After that you are able to Request.Files like you normally would do from controls.