Frank van Rooijen
 

Implementing CSS friendly ASP.NET 2.0 control adapters in Sharepoint 2007 - Update

27

Mar

As some people have found out, implementing the css adapters in MOSS 2007 can be quite frustrating. Even for myself.
After half a year of doing nothing with MOSS and wrapping up my old projects. I started working with MOSS again. Off course I wanted to work with te latest version of MOSS with the latest version of the CSS-Friendly adapters.
Both versions were upgraded and my previous described solution didn't work anymore. So I needed to get back to the drawing board.

Actually the basics of my solution still stands, but MOSS doesn't uses the ASP.BrowserCapsFactory from the Global Assembly Cache anymore. So you need to copy the CssAdapter.browser file to your MOSS websites App_Browsers directory (C:\Inetpub\wwwroot\wss\VirtualDirectories\80\App_Browsers). You actualy need to do this for each of your MOSS-website.

While I was at it I also needed to figure out a way to stop all the menu controls from using the CSS-Friendly controls in MOSS. That was actualy quite easy. In the WebControlAdapterExtender.cs is a boolean called "AdapterEnabled", you need to alter this property. This property automaticly assumes that every control will use the adapter. We want to invert this. So that the adapter is standard disabled. In your MOSS code you can add the attribute AdapterEnabled="true", if you want to enforce the adapter on your control. It will look something like this:

Thats is for now, if you encounter any problems don't hesitate to send me a note.

Categorie:
Share:

Frank van Rooijen schreef

Comments (0) | Permalink

Frank van Rooijen

Frank van Rooijen schreef

Comments (0) | Permalink

Frank van Rooijen

Browsercaps for all

28

Oct

Two months ago I started working on a new project for the Dutch government, the site must comply with all the standards specified by this government (http://webrichtlijnen.overheid.nl/). One of the guidelines is to use xhtml-strict and stylesheets for the markup for their sites. So we started building this according to all the specified standards. We delivered the project as planned, to my surprise the test results told us that the site was not build according by the xhtml-standard.

To validate all the pages I use Firefox with the web developer plug-in. When I was finished to validate all pages I couldn’t reproduce the malfunction, all my pages were xhtml-strict. I was a bit confused, but after a bit of mind bending I could reproduce the error. I validated my local html rendered by my Firefox client (Ctrl+Shift+A) instead of the html that was rendered by the W3C-client. Now that I found the problem I could start focusing on the solution.

When .NET renders it’s code for a client, it uses browsercaps to determine the compatibility mode for the client. If the client, that requests a rendering of html, is not recognized by .NET it tries to render html that is compatible for ancient browsers. By altering your browsercaps it is possible to make the W3C-client available and make it an up-level browser. But nowadays nobody actually uses low-level browsers. We want to use xhtml so that all browsers can interpret our mark-up code. So we need to level-up all the browsers and render very well formed xhtml for all the browsers. If you are familiar with browsercaps you probably know what to do now. But for the people who don’t know I have written a small how to.

How to up-level all the clients with browsercaps*

If you open your web.config you have a section browsercaps or you can create one. In this section you normally specify a lot of different browsers and their capabilities. But what if all the browsers should render the same mark-up. Just paste the following xml in your web.config and all off the browsers render the same mark-up code in xhtml strict.

<system.web>
    <xhtmlConformance mode="Strict" />
    <browserCaps>
        frames=true
        tables=true
        cookies=true
        javascript=true
        javaapplets=true
        ecmascriptversion=1.5
        w3cdomversion=1.0
        css1=true
        css2=true
        xml=true
        tagwriter=System.Web.UI.HtmlTextWriter
    </browserCaps>
</system.web>

*this applies to .NET 2.0 applications

Categorie:
Share:

Frank van Rooijen schreef

Comments (0) | Permalink

Frank van Rooijen

Switching from MCMS 2002 to MOSS 2007

01

Sep

If you are an MCMS developer and you want to know what changes for you when switching to MOSS 2007, Microsoft wrote an Technical article about SharePoint Server 2007 for MCMS 2002 Developers

Categorie:
Share:

Frank van Rooijen schreef

Comments (0) | Permalink

Frank van Rooijen

Workflow in Content Management

31

Aug

Implementing workflows are very importent while manageing content. We can use it for approval purposes, but there are also a number of other possibilities.

Some other examples:

  • Automatic processing of information
  • Haversting feedback
  • Keep track of documents and records in your system

David Chappell, wrote a whitepaper about Understanding Workflow in Windows SharePoint Services and the 2007 Microsoft Office System. This document describes how to implement workflow in Microsoft Office SharePoint Server 2007.

Categorie:
Share:

Frank van Rooijen schreef

Comments (0) | Permalink

Frank van Rooijen

Implementing CSS friendly ASP.NET 2.0 control adapters in Sharepoint 2007

18

Aug

Introduction

I work as a Microsoft Content Management Server (MCMS 2002) developer at Tam Tam. To make a step into the future I attended an introduction course of SharePoint 2007. Because the MCMS 2002 product will be part of SharePoint 2007. At this moment we are trying to deliver all our sites according to the latest Accessibility Guidelines. As SharePoint developers probably know Microsoft loves to render their products with tables. This trend was also followed when Microsoft introduced the .NET 2.0 Framework. For example the Menu control is default rendered as a table. This control is extended in SharePoint 2007 (AspMenu), but still renders as a table.

Other developers recognize this problem as well and started to write white papers of how to implement CSS friendly adapters in your website. All these white papers describe that you will need a .browser file that is compiled with your code. For a website project this is no problem, but when using Microsoft SharePoint 2007 you will get a precompiled web-site OOB. This is a problem when you want to implement the adapters. Together with some collegues of the teacher (Patrick Tisseghem, u2u) we made a proof of concept to implement these adapters in SharePoint 2007. So how is it possible to use these adapters within SharePoint 2007.

Implementing the proof of concept

To get started download the Css Friendly ASP.NET 2.0 Control Adapters from the Microsoft site. The ASPNETCssFriendlyAdapters_beta1.1.vsi will add some new projects to your Visual Studio 2005.
Install screen

After the installation open Visual Studio 2005 and create a new web-project based on the Css Friendly ASP.NET Control Adapters.
This will provide you with all the code we are going to use.
open a web-project

To make the code for the adapters available in SharePoint 2007 we need to create a new project which is based on a Class Library.
create a new class library

In the Folder App_Code there are two folders we will need to copy the files form the directory Adapters to our just created Class Library and add the missing refferences. You are free to alter the code and make it compliant with your own whishes.
Copy the code

Now you can sign and rebuild your Class Library so we can install it in the GAC. Copy the CssAdapters.dll to the assembly folder in the Windows folder or use the gacutil.exe to register the dll in the GAC.
Copy a binary in your GAC

Now we get to the question how we can register the .browser file and make it available for SharePoint 2007. It is possible to extend the browser descriptions on your whole machine. By using the aspnet_regbrowsers.exe. Before we can do this we need to alter the current CssAdapter.browser file so it wil use the CssAdapters.dll from our GAC.

<browsers>
   <browser refID="Default">
      <controlAdapters>
         <adapter controlType="System.Web.UI.WebControls.Menu"
               adapterType="CSSFriendly.MenuAdapter, CssAdapters, 
                                    version=1.0.0.0, 
                                    Culture=neutral, 
                                    PublicKeyToken=<Your Token>"/>
      </controlAdapters>
   </browser>
</browsers>

Replace the Version and the PublicKeyToken with your own. You can find this to get the properties of the assembly in your GAC.
get the properties from the assembly

Copy the CssAdapter.browser to the folder: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\Browsers
Open a Visual Studio 2005 Command Promt so we can rebuild and register the browser extentions.
recomile the brwosers directory

Now You can visit your portal site and check out what just happened.
compile the browsers directory

Conclusion

This proof of concept shows you the steps of how to implement the CssFriendly Control Adapaters in your SharePoint 2007 solution. There are still some problems to be solved in the Architecture. Because all the sites that are created with SharePoint 2007 depend on the HTML structures provided by these Controls you need to alter all the pages that are used by SharePoint 2007. This is a bad idea, it is better to create a control that simply inherets from the control which you want to use with your adapter and specify the inhereted control in your browsers file. This way you have full control on where you want to use the adapter in SharePoint 2007 or web-site.

References

Categorie:
Share:

Frank van Rooijen schreef

Comments (0) | Permalink

Frank van Rooijen

Zoeken

Categorie

Archief


Sign In