February 2007 - Posts

To get started with the ASP.NET AJAX extensions in SharePoint 2007, check out my previous posts:

Once you fell in love with ASP.NET AJAX, you have to check out the ASP.NET AJAX Control Toolkit! The ASP.NET AJAX Control Toolkit provides a set of sample controls and extenders that makes it a snap to spice up your web site with rich functionality. Think about the Control Toolkit as a bunch of sexy controls which use the ASP.NET AJAX extensions, plus a framework to create a new even sexier control on your own. In this post I'll describe how you can make use of the Control Toolkit in your SharePoint 2007 sites, for example by using the SmartPart.

Actually SharePoint doesn't differ from any other ASP.NET web site to use the Control Toolit, there are only three things that you need to do:

  1. Make sure SharePoint has access to AjaxControlToolkit.dll
    You can do this in two ways: either you deploy the assembly to the Global Assembly Cache (GAC) or you put in the \BIN folder of the SharePoint site's folder.
  2. Add an assembly reference in the web.config (note: for the future versions of the Control Tookit, the version number can change!):
    <assemblies>
        ...
        <add assembly="AjaxControlToolkit, Version=1.0.10201.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"/>
        ....
    </assemblies>
  3. Add the tagprefix for the Control Toolkit in the web.config:
    <controls>
        ...
        <add namespace="AjaxControlToolkit" assembly="AjaxControlToolkit" tagPrefix="ajaxToolkit"/>
        ....
    </controls>

That's it! Now you can make use of the Control Toolkit coolness in your SharePoint 2007 sites! If you want to test if the Control Toolkit is working on your installation: I've upload a very small example to CodePlex.

 

 

Technorati tags: , , , , ,

As you may know, last week I released a version (still in beta) of the SmartPart which supports the ASP.NET AJAX extensions. For more information about this version of the SmartPart, see my previous blog post.

This weekend I've been working on functionality to support "AJAX connection" in the SmartPart. First of all; connectable web parts are web parts that can exchange data. Think for example about a web part which displays a list of invoices, and another one that displays a list of invoice lines. If you select an invoice in the first one, the second one can display the lines of the selected invoice. So with connectable web parts you can create those typical parent/child and parent/details relationships. You can create connectable web parts in SharePoint 2003 and in ASP.NET 2.0/SharePoint 2007, so it's not a new functionality.

So why are the connections in the new version of the SmartPart (Return of SmartPart v1.2 BETA) so special? Well if you combine web part connections with a little bit of AJAX-magic you have web parts that can exchange data without postbacks! Think about selecting the invoice and displaying the corresponding invoice lines in another web part, all without postbacks. Actually you could do that trick without this new version, but I've added some helper and wrapper classes to make your life as a web part developer a little bit easier!

Let's start with a really basic example: the DemoProvider and the DemoConsumer user controls. The first one has an UpdatePanel (the ASP.NET AJAX control handling the partial-page rendering), a TextBox and a Button. The second one just has an UpdatePanel and a TextBox. The scenario should be like this: the user enters some text in the first text box, clicks the button and the text is transferred to the second text box, all without postbacks.

 

public partial class DemoProvider : System.Web.UI.UserControl,
                             
SmartPart.IConnectionProviderControl
{
  protected void Page_Load(object sender, EventArgs e)
  {
}

  public string ProviderMenuLabel
  {
    get { return "Send test data to" }
  }

  public object GetProviderData()
  {
    return new SmartPart.AJAXConnectionData(
      TextBox1.Text, Button1, "Click");
  }
}

The code above is the code for the DemoProvider user control, notice that the class implements the IConnectionProviderControl interface of the SmartPart which is also used for normal connections. The special thing happens on the GetProviderData method; a new instance of the AJAXConnectioNData class is created. This object contains first of all the value that should be send to the consumer (TextBox1.Text). The second parameter is the control that will cause the UpdatePanel to refresh, the third parameter is the name of the control's event which will cause the refresh. (This constructor can only have one control as a trigger control, but the class can hold more than one.) The ProviderMenuLabel property returns the value which will be displayed in the web UI of SharePoint when the connection is made. That's it! Now let's take a look at the code for the DemoConsumer user control:

public partial class DemoConsumer : System.Web.UI.UserControl,
                                 
SmartPart.IConnectionConsumerControl
{
  protected void Page_Load(object sender, EventArgs e)
  {
}

  public string ConsumerMenuLabel
  {
    get { return "Receives test data from" }
  }

  public void SetConsumerData(object data)
  {
    SmartPart.AJAXConnectionData ajaxData = data as SmartPart.AJAXConnectionData;
    if (ajaxData != null)
    {
      ajaxData.RegisterTriggerControls(UpdatePanel1);
      if (ajaxData.Data != null)
        TextBox1.Text = ajaxData.Data.ToString();
    }
  }
}

The class implements the normal IConnectionConsumer control of the SmartPart and once again the special thing happens in the SetConsumerDate method. This method receives the instance of the AJAXConnectionData class which was constructed by the provider. First the code checks if the data received is an AJAXConnectionData instance, if so the RegisterTriggerControls method is called with the UpdatePanel to use as a parameter. This method will add every control of the AJAXConnectionData instance as a trigger control for the UpdatePanel, so the two UpdatePanels of the two user controls can trigger eachother. You could do this manually as well, but I provided this functionality since it will be the same for in like 99% of all the cases. Finally the Data property is used to fill the TextBox's Text property. Done!

I could show the result with some screenshots, but you have to see them in action to get the idea. That's why I've recorded a small screencast of the two user controls. The second part of the screencast shows some other controls which get data from the AdventureWorks database. I already put them on a site, so you can see the Categories web part connected to the Subcategories web part, which is connected to the Products web part. You can download the source code for these demos from CodePlex.

Downloads:

There has been a lot of buzz around SharePoint support for ASP.NET AJAX the last couple of days, resulting in some nice posts, even from the Microsoft guys. If you are new to the topic; some required reading:

  • Integrating ASP.NET AJAX with SharePoint (by Mike Ammerlaan)
    Mike clearly described what you need to do to get the ASP.NET AJAX extensions working in a SharePoint site. First install the extensions (of course), then make some changes to the web.config of the SharePoint site.
  • AjaxBasePart: Easy ASP.NET 2.0 AJAX Extensions 1.0 and Office SharePoint Server 2007 (by Eric Schoonover)
    Eric describes how you can make use of ASP.NET AJAX in a SharePoint web part, he posts code for his implementation of a base web part class that supports AJAX. The nice thing about this base web part class is that it dynamically adds the AJAX ScriptManager control to the class (required for the AJAX stuff).

Yesterday evening (very late :-) ) I've created a version of the SmartPart that makes use of the Eric's technique, let me introduce you the SmartPart with AJAX! So basically said: you can create a Web User Control (ASCX) with the Visual Studio Designer, that uses the ASP.NET AJAX extensions and run that user control as a SharePoint web part. At this point in time, it's still a beta version, you can get it from the GotDotNet workspace (releases section). How do you get started? First of all you need to download and install the ASP.NET AJAX Extensions. Next you need to extend your SharePoint site with these extensions, check Mike's post for detailed instructions. You only need to change the web.config, you don't need to add the ScriptManager to the master page! Now you can install the SmartPart (check the Installation guide, or this screencast).

Now you can start building ASP.NET AJAX style user controls and use them in SharePoint! The beta version of the SmartPart ships with a couple of examples, but I've recorded a small screencast (no sound yet) as well, you just need to see AJAX in action, screenshots don't give you an idea about how the web parts behave without postbacks. Just watch the demos and see how easy it is! :-)

To finish of I would like to thank two persons who helped me with this release of the SmartPart. First of all Eric Schoonover for posting the code for his AjaxBasePart and for the support via Messenger. :-) Secondly I'd like to thank my friend and colleague Kevin DeRudder (still no blog?) who introduced me to the wonderful world of AJAX and helped me a lot with the demos.

Here's a screenshot of the Calendar control from the ASP.NET AJAX Control Toolkit, hosted in a SmartPart on a WSSv3 site:

 

Mike Ammerlaan (PM for WSS) stepped up and posted a detailed article about the integration of ASP.NET AJAX and SharePoint.

Here's an interesting section:

Here are some common scenarios in SharePoint you should be able to achieve with Microsoft ASP.NET AJAX 1.0:

  1. Building a more powerful, re-usable JavaScript libraries you can use in your web controls and parts
  2. Enabling your web services to render via JSON, resulting in easier usage in JavaScript/Ajax Applications
  3. Building a web part that takes advantage of Extender technology to provide richer interaction styles, such as autocomplete on a textbox.
  4. Using an UpdatePanel in your web part or control for more fluid, no postback interaction. (this will require some workarounds, however.)

Recommended reading: the full article.

Technorati tags: , , , ,

Service Pack 2 for SQL Server 2005 has RTM-ed! Why do you read SQL related stuff on my blog? Well this service pack includes the long awaited Reporting Services web parts for SharePoint 2007 (WSS v3 and MOSS 2007). From the what's new page:

You can integrate a report server instance with Windows SharePoint Services 3.0 or Microsoft Office 2007 SharePoint Server to store, secure, access, and manage report server items from a SharePoint site. Integration features are provided jointly through SP2 and a special Reporting Services Add-in that you download and install on an instance of the SharePoint technology you are using.
The new Report Viewer Web Part is included in the Reporting Services Add-in that you install on a SharePoint technology instance. For more information about the Web Part and other integration features, see Reporting Services and SharePoint Technology Integration and Features Supported by Reporting Services in SharePoint Integration Mode.

Get it from the MS Download site!

I just noticed that Virtual PC 2007 is now available! Get it from the MS download site (free!).

Technorati tags:

This is cool and funny, it's like a wizard to generate a wizard! Nick Dallet has posted an InfoPath form which can generate a UDC file. More details and download on the InfoPath team blog:

Some time ago, we blogged about the reasons why you'd use UDC files and the anatomy of UDC files. You may be wondering, however, if it's possible to author these files in InfoPath - after all, UDC files are just XML files. You're right - this is definitely possible. Attached to this article is a form template that lets you author and edit UDC files. full post here

Technorati tags: ,

Robert Scoble and Thomas Hawk (famous photographer) introduced the concept of "photowalking". From Wikipedia's definition of photowalking:

Photowalking is the act of walking with a camera for the main purpose of taking pictures of things you may find interesting. ... While closely related to Street Photography, photowalking is differentiated by the main impetus being to photograph things of interest rather than people specifically. It is also often done as a method to practice and improve one's own photography skills rather than a with specific focus on documentary photography.

For me photowalking would be hanging out with a bunch of people and taking photo's of some interesting things so we can all have a good time and learn from each other. If you want to get the idea; check out Robert's Scobleshow.

Due to a recent conversation on Jelle Druyts' blog, Jelle and myself got the idea of organizing a photowalk in Belgium. Jelle nicely wraps it up:

Digital or film, beginner or pro, cellphone, compact or SLR camera, kilopixels or megapixels, Java, .NET, php or Cobol, it doesn't matter - you're all welcome as long as you're interested and can cope with people stopping every 10 seconds to take pictures So it's nothing official, it's not a course, it's just a day to hang out with some fellow passionado's, have some fun, get to know some new people, exchange ideas and tips, and make some great pictures.

These are the details so far:

  • Place: Brussels (exact location to be discussed)
  • Time: Saturday 3rd of March, or Sunday 4th of March at 10 am

As soon as we've set the details we'll create an event on Upcoming.org, in the meanwhile I invite everybody to drop a comment on Jelle's blog if you're interested to join us and/or if you have some suggestions for the place and/or time. 

It's not the first time that both Patrick and myself are in Africa at the same time, but it's the first time that we are at the same time in the same country: South Africa! This week Patrick is in Cape Town for the MS EMEA SharePoint 2007 Tour and I'm doing the same thing in Johannesburg.

So far it has been a great week; I'm training almost 30 SharePoint fans and the weather is fabulous (around 30 degrees C). Tonight there was a big thunderstorm and with some luck (I had to take more than 50 long exposure shots) I could snap this photo (full size on Flickr):

Being here is actually very funny and strange: in South Africa it's summer (it's in the southern hemisphere) and in Belgium it's winter (it's in the northern hemisphere). It's not only the difference in temperature, but the people here are also in a summer mood! Just imagine: I'm sweating over here in my t-shirt and wife just showed snow falling from the Belgian sky via the web cam ...

Yesterday I attended one of the sessions Scott Guthrie presented at the VISUG event in Mechelen (Belgium). In this session Scott covered some of his ASP.NET 2.0 and ASP.NET AJAX tips and tricks: cool stuff. When started talking about ASP.NET AJAX the audience (+300 people!) started asking some questions, in my turn I asked Scott about using ASP.NET AJAX in SharePoint 2007. Scott confirmed Daniel's statements (not supported, only use the the client side scripts, server-side controls don't work, etc), but more interesting; he told the audience that ASP.NET AJAX will be supported in SharePoint 2007. How is Microsoft going to pull off this trick? <quote>ASP.NET Ajax will be supported in SharePoint when we release a service pack for SharePoint, we will ship it later this year.</quote> Great!!

Another statement that Scott made, (which actually contradicts Daniel's statement) was about using the UpdatePanel in web parts. According to Scott you can make use of the UpdatePanel in SharePoint, when it's hosted in a web part. Mmmm, let's find some more information about this. I'll definitely need the help of my colleague Kevin (hey Kevin, now it's really time to start a blog!!) to get me on speed with ASP.NET AJAX.

Side note: kudos to VISUG (Visual Studio User Group Belgium) and MSDN Belux for organizing this (free!) event, a job well done! It was great to meet so many (old) friends, ex-colleagues, students, ... during the break, I didn't even have time to say hi to everybody I know.

Side note 2: the SmartPart also got some exposure! Scott mentioned it when he answered a question from the audience, I guess he didn't know that Belgium is not only the land of the chocolate, but it's also the land of the SmartPart! :-)

 

Technorati tags: , , ,
More Posts Next page »