Thursday, February 26, 2009

Remember to Serialize objects when saving to web part properties

Remember to set the [Serializable] attribute to the web part property you are using to save your data when saving objects, e.g. saving objects to an arraylist web part property.

Strings do not require the [Serializable] attribute to be specified.

Monday, February 23, 2009

Associated PDF file type with PDF icon

1. Find or Create an icon file you want to use (16x16 pixels)

2, Copy the icon file (.gif) to the location: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\IMAGES

3. Go up a level and go to the XML folder in the templates directory: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\XML

4. Open the DOCICON.xml file.

5. Go to the section

6. Go to the bottom of the section.

7. Add an entry for the PDF icon gif:

8. Save file and exit.

9. Perform an IISRESET


For pages with existing links you wish to have the icon attached to it, you will need to re-enter them in. Refreshing the page does not update the link with the icon you have specified.

Wednesday, February 18, 2009

Invalid Page Layout error





Issue was corrected after removing an extra ~ from the PublishingPageLayout values.

Tuesday, February 10, 2009

Content Place Holder issue


A place holder was placed inside another placeholder.......

Once the place holder was taken out of the other one, problem fixed.

Duplicate web parts, error, Get it working.

There may come a time when there is a requirement that a web part be used multiple times on a web page.

Often, depending on the behavior of the web part, the web part/s may function incorrectly.

There was a web part I developed and the business user needed it to be displayed more than once on a page. My web part contained JavaScript as well as server side code.

SOLUTION: A solution would be to attach the web part ID to each JavaScript method and call. Hence making each instance of the same JavaScript method unique. If you have two of the same web parts on the page, each of those web parts will have a different web part ID. Web Part A will be calling Web Part A JavaScript Method and Web Part B will be calling Web Part B JavaScript Method.

Also attach the web part ID to the RegisterStartUpScript name. This will prevent your second JavaScript overwriting your first JavaScript method. If this happens, you will get JavaScript errors if you try to do something on your first web part because the methods it needs to call are missing.

As long as methods all have unique names, and on post back you are checking for the EventArgument correctly. You can attach a hashed string containing the post back argument parameter '#' web part ID.

Monday, February 9, 2009

Temporary ASP.NET files cache causing errors

Files like CSS, master pages, CSS Adapters etc, get cached in the Temporary ASP.NET files. These files do not get updated regularly.

After a few site definition deployments, I realised that there was something going on because my master page files were not being picked up even though they have been deployed to the 12 Hive. Features were re-activated, CTRL+F5-ed the web site, still no fix.

So after clearing the temporary files located at:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files

The web site picked up the new files I deployed.

Master Page: Getting File not found error after the location of the master page has changed in the site definition project

This error appeared after the master page was moved locations in the Visual Studio project solution. I deployed the solution and refreshed the default page.

Clear the .Net Temporary files and other caches did not fix the error.


Solution:

After removing the site collection and recreating it fixed this issue.