Windows 7 – Fix the explorer not auto-refreshing bug
20One of the most irritating bug still present in Windows 7 is explorer not auto-refreshing when creating a new folder or copying/moving/renaming a file. The apparent cause to this problem is when you map network drives in My Computer. Turns out the fix is quite simple (or at least it worked for me):
1) Open My Computer and click Organize > Folder and Search Options
2) Under the View tab, uncheck the Hide protected operating system files (recommended) option.
3) On your desktop, you should now see 1 or more Desktop.ini files. Delete all of them (no, it won’t break your system, they are auto-generated).
4) Reboot your computer. Problem solved!
Note: I still get the bug when copying or moving files from a network drive but anything done locally on the computer seems to work again.
You might want to re-check that setting in Folder and Search Options once you’re done.
C# – Keep user settings between versions
5Unless you’re using the ClickOnce deployment method for your applications, user settings are usually not transferred when updating to a new version of a C# desktop application. There’s in fact a quick and simple way to always keep the settings between versions.
The trick is to call the .upgrade() method your app settings object. The system will look for previous versions of your application in the App Data directory and copy the user settings to the new version automatically.
Properties.Settings.Default.Upgrade();
But now we have a problem. How do you know when the upgrade method should be called? As we don’t want to upgrade everytime the application is started, but only the first time after an upgrade. The solution is to create a new user settings variable that will be used to determine whether an upgrade is required. You can either make it a string and save the current application version, or make it a boolean and set it to True by default. I personally find the boolean method easier to use and this is the one I will explain below:
In your application load function (private void Window_Loaded in WPF), simply use this code:
if (Properties.Settings.Default.UpdateSettings)
{
Properties.Settings.Default.Upgrade();
Properties.Settings.Default.UpdateSettings = false;
Properties.Settings.Default.Save();
}
It is important to place this code before anything else that use the user settings in the load method. In the above example, UpdateSettings is the user setting variable I created and set to True by default. When the application launch, it will check whether the UpdateSettings variable is set to True. If it’s the case, it will perform an upgrade. We then set the variable to False so that it doesn’t perform an upgrade the next time. Finally, we save the new settings. Why does it work? Because we set the user setting to True by default which will only occur after a new installation of the application.
Enjoy!
Sharepoint – Masterpage User Controls Limit
0If you insert more than 10 user controls in a masterpage, you might get an error similar to this:
The page ‘/path/somefile.master’ allows a limit of 11 direct dependencies, and that limit has been exceeded.
You can easily increase that limit as it is actually set in your sharepoint web.config:
1) Browse to C:\inetpub\wwwroot\wss\VirtualDirectories\
2) Open the folder corresponding to your Sharepoint website.
3) Edit the file web.config
4) Do a search for “safemode“.
5) Change the property DirectFileDependencies from 10 to a value your choice.
6) Do an iisreset command and you’re done!
Sharepoint – The missing configuration screen
1This Sharepoint Configuration Wizard screen was removed from the final Sharepoint build, at the very last minute:
![]()
Sharepoint 2010 – Display compilation errors
3By default, Sharepoint displays a friendly error box that tell pretty much nothing about the error that just occurred. It is possible to display the default yellow screen of death with all the details, found in usual ASP applications.
1) Navigate to C:\inetpub\wwwroot\wss\VirtualDirectories\
2) Open the Sharepoint web application folder you wish to edit.
3) Edit the web.config file.
4) Find the property customErrors and set it’s mode value to Off.
5) Find the property compilation and set it’s debug value to true.
6) Find the property SafeMode and set it’s CallStack value to true.
7) Do a iisreset.
Done!
Sharepoint 2010 – Custom Error Pages
4Unless you love the default Sharepoint error pages for 404 (not found) and 401 (access denied), it is usually a good idea to change them. The steps are a bit different than a standard ASP.net application.
1) Browse to C:\inetpub\custerr\
2) You should now see a list of localization folders like en-US or fr-FR. Open the folder you want to edit and modify the error pages for 401,403,404 and 500.
3) Now browse to C:\inetpub\wwwroot\wss\VirtualDirectories\ and open the folder associated to the Sharepoint site you would like to affect.
4) Edit the file web.config and find the keyword customErrors. Replace the complete customErrors code block with:
<customErrors defaultRedirect="404.htm" mode="On"> <error redirect="401.htm" statusCode="401" /> <error redirect="403.htm" statusCode="403" /> <error redirect="404.htm" statusCode="404" /> <error redirect="500.htm" statusCode="500" /> </customErrors>
5) Now find the keyword <system.webServer>. Inside this block, place the following block code. (If the httpErrors block already exists, replace it completely!)
<httpErrors errorMode="Custom" existingResponse="Auto"> </httpErrors>
6) Save web.config and do the usual iisreset command if needed.
ASP.net – Using multiple forms on the same page
3One if the big issue with ASP.net programming is having multiple forms on the same page. You can only have 1 form with runat=”server” on your page or it will throw an exception. When you have a form on your page and search box in your header, it can cause some big issues when you press Enter. The wrong postback will be triggered in the second form.
The solution is to use an <asp:panel> with a defaultbutton around each of your “HTML forms”. There’s only 1 form containing the whole page with 1 panel for every “HTML form”. By “HTML form”, I mean a series of inputs that are part of the same logical group and not an actual <form> tag.
Pressing Enter in any textbox will now trigger the correct default button. Problem solved!
Sharepoint – Access QueryString from custom webpart
2I was trying to access the QueryString parameters inside a custom webpart coded in C#. I would usually use Request.QueryString but the Request object was simply not available in this case. Turns out it is found under the Page object:
string kquery = Page.Request.QueryString["kqry"];
Sharepoint Designer – “The server could not complete your request” error message
3I started getting this error message yesterday while working in Sharepoint Designer. I would get the message whenever I would open a Sharepoint website. The solution to this problem is quite simple:
1) Open Internet Information Services (IIS) Manager.
2) Expand your computer list on the left then click on Application Pools.
3) Locate the application pool used by your Sharepoint website.
4) Right-click on the application pool and select Recycle.
You should now be able to connect to your Sharepoint website using Sharepoint Designer as usual.
CSS: How to remove the dotted outline on links
0When you click on a link element, it becomes focused and displays a dotted border around it. In some case, you might want to remove that outline for aesthetics, especially on menu links that are displayed as block elements. To remove that outline, simply place this CSS line of code:
a:focus {
outline:none;
}
In the above example, all links that become focused won’t display the outline.
Keep in mind that hiding that outline will prevent people use keyboard navigation to see which element is selected.