Wednesday, October 25, 2006

Detecting IE7 in JavaScript

I've tried this method and it works great. This little tip will come in very handy.

Ajaxian � Detecting IE7 in JavaScript: "Detecting IE7 in JavaScript"

Tuesday, October 24, 2006

IE7 and SharePoint

I installed IE7 on Monday to start testing how well the full release of the browser worked with SharePoint. Everything worked great except that I started getting the yellow dropdown box saying:

"This website wants to run the following add-on:'owsclt.dll' from 'Microsoft Corporation'. If you trust the website ...."

You can click and allow the add-on to run but there are quite a few of these add-ons that SharePoint tries to use and it would get old having to click to allow the add-on (or even just hearing the beap and seeing the yellow dropdown gets old quick). A quick fix that I found is that if you trust the owner of the SharePoint site you can add the site to your trusted sites and you'll never see the yellow dropdown box for that site again.

Here are the basic steps to add a site to your trusted sites:
  1. Click Tools menu and then click Internet Options
  2. Click the Security tab
  3. In the 'Select a zone to view or change security settings' box, select Trusted sites
  4. Click the Sites button
  5. In the 'Add this website to the zone:' field, you should see the url for the SharePoint site. If not go ahead and add it to that field.
  6. Click the Add button
  7. Click the Close button
  8. Click the OK button
  9. You're done

Tuesday, October 17, 2006

RegisterClientScriptBlock isn't adding the script to the page

I have a bunch of ASP.NET custom controls that I've written to simpilfy some things that we do all the time (like disable a submit button after a click). To achieve a lot of this functionality, I've written some javascript and had them emitted via the Page.RegisterClientScriptBlock method.

When we converted these controls to ASP.NET 2.0, the script blocks no longer were being written to the page. Luckily I found a blog that mentions that the Register Script calls need to be done in the OnPreRender event because if you it do it in some other event, it will be too late.

Please note that the Page.RegisterClientScriptBlock has been deprecated and replaced by Page.ClientScript.RegisterClientScriptBlock (Thanks to Travis for reminding me to point this out).

Source: Page.RegisterClientScriptBlock isn't adding the script to the page...:

Monday, October 16, 2006

HTML Validation Checking in VS 2005

I'm trying to do some fancy stuff with CSS in my VS 2005 ASP.NET 2.0 web project. Some of the things that I am doing cause my css to not be "Well-Formed". By default VS 2005 validates your CSS and lets you know how crappy of a CSS crafter you are. I finally got tired of it and found this article that tells you how to disable the smarth mouthy validator.

HTML Validation Checking in VS 2005

Theme and Skin Starter Kit

After learning about themes and skins, I wanted to find a some predone themes to give me some ideas to "borrow". Here's one web site that gives you a starter kit.

.NET TREATS & TRICKS :: TOOLS: "ASP.NET 2.0 Colorful Web Site Starter Kit"

Friday, October 13, 2006

Enabling IntelliSense in a Skin file for Visual Studio 2005

We've been going over the new Theme and Skin functionality in ASP.NET 2.0 when I noticed that the IntelliSense was not activiating to help create the skin file. One of my coworkers found the following steps to enable IntelliSense:

  1. Go to Tools->Options menu.
  2. Pick Text Editor -> File Extesion.
  3. Type skin in Extesion text box.
  4. Select User Control Editor from Editor dropdown.
  5. Click Add and then Ok to close dialog and re-open your skin files.

Source: CKCMoss.com: "How to enable intellisense for Skins in 2.0"

Thursday, October 12, 2006

Just learned a handy tip

I just learned that you can click and drag a file or folder from windows explorer on to a command prompt window and it will insert the path to the file/folder into the command prompt prompt. I had no clue that you could do it. Was I the only one in the dark on this one?! Oh well, now I can become even more efficient.

Wednesday, October 11, 2006

VS 2005 and Refactoring

VS 2005 has a new context menu item titled "Refactor". It has all sorts of goodies (check the image below).



I would have given quite a bit of money for any one of these options and now they're all included for "free".

The Rename option changes all references to a property or method (does not just do a find and replace). The coolest option that I saw was the Extract Method option. It allows you to hightlight some code and then it pulls the selected code into a new method and pulls in the needed variables and references.

I am most definately sold on this VS 2005 thing.

VS 2005 and Code Snippets

I love code snippets in Visual Studio 2005. Code snippets are a new feature in VS 2005 that allows you to quickly insert code pieces into your source code. For example, to get a for loop structure: type in for and hit the tab button twice. It will insert the for structure and allow you to quickly change the looping variable's name and loop limit. You can also create your own code snippets or modify your own (located in the C:\Program Files\Microsoft Visual Studio 8\VC#\Snippets\1033\Visual C# folder)

.NET 2.0 and VS 2005 - Nullable Value Types

We're finally getting some training on .NET 2.0 at work. I'll be posting things that I find interesting in the next couple of days.

One of the first things that I really liked is the ability to have nullable value types. For example, let's say that you have an integer for tracking some value and it can be positive and negative. It is also possible for the value to be not set yet. How do you detect that the value hasn't been set yet? You typically come up with some arbitrary number like 99999999 and hope that the real value is never actually 999999999. In .NET 2.0, they have the ? syntax that allows you to set a value type (ie int, long, struct, etc) to null. For example the following code would not compile in 1.1 but works wonderfully in 2.0:

class MyClass
{
private int? someValue;

public MyClass()
{
someValue = null;
}
public int GetSomeValue()
{
if( someValue != null )
{
return someValue;
}
else
throw new Exception( "Some Value has not been set" );
}
}

This is a much cleaner and safer way than checking for some arbitrary number like 999999999.

Tuesday, October 10, 2006

SharePoint 2007, .NET 2.0 and UserControls

We've been using SmartPart like functionality to load UserControls into our web parts. We are in the process of converting our code to work with SharePoint 2007 (which also includes upgrading the code to .NET 2.0 as well). As some of you might be aware, ASP.NET 2.0 makes use of an _app_bin folder to store compiled code. So I assumed (BIG MISTAKE) that's where the dlls for webparts that load user controls should go. After several days of the webpart not being able to load the user control's dll, I had someone point me to this lovely URL . As you can see, the dll's actually don't go in the _app_bin directory. They still go into the bin directory or GAC.

Saturday, October 07, 2006

SharePoint 2007 Bookmarklets

After beginning a project that uses SharePoint 2007, I tried using my old SharePoint 2003 Bookmarklets, discussed here, and low and behold they still work. These little guys sure have come in handy.