Walkthrough: Creating a Custom ASP.NET (ASMX) Web Service in SharePoint 2010

There is a walkthrough on this subject on MSDN. I’ve seen a few people comment that they have had issues trying to follow the walkthrough so I thought I’d create an alternate version.

Update: A couple of people have asked for information on how to consume the service so I’ve added an extra section at the bottom.

Creating the ASP.NET Web Service

  • In Visual Studio, click File | New | Project…
  • In the New Project dialog, select the Visual C# > SharePoint > 2010 node under Installed Templates.
  • Select the Empty SharePoint Project template, set the Name to WebServiceDemo and click OK.

    image

    • In the SharePoint Customization Wizard, enter the site you want to use for debugging, select Deploy as a farm solution, and click Finish. We are creating a farm solution because we need to deploy files to the SharePoint system folders (14 hive).

      image

      • In the Solution Explorer, right-click on the project and select Add | SharePoint “Layouts” Mapped Folder. You should see two new folders added to your project.

        image

        Note: Normally web services go into the ISAPI folder. However, if we do that we will need go through all of the pain steps in the Generating and Modifying Static Discovery and WSDL Files section of the original walkthrough. Instead we are going to put the web service in a folder under the Layouts folder where these steps are not required. I have used this technique in the past have have not found any reason why custom ASP.NET web services should not be deployed under the layouts folder.

        • Right-click on the newly created WebServiceDemo folder, and select Add | New Item…
        • In the Add New Item dialog select Visual C# > General from Installed Templates, set Name to MyCustomWebService.asmx and click Add.

          image

            <%@ WebService Class="WebServiceDemo.MyCustomWebService, #assembly strong name# %>
            • In the Solution Explorer, right-click on the project and select Add | Class…
            • In the Add New Item dialog, set Name to MyCustomWebService.cs and click Add.

              image

              • Before we add the code to the class, we need to add a reference. In the Solution Explorer, right-click on the project and select Add Reference…
              • In the Add Reference dialog, select the .NET tab, select System.Web.Services, and click OK.

                image

                • Inside the MyCustomWebService.cs file, replace the code with the following.
                  using System;
                  using System.Collections.Generic;
                  using System.Linq;
                  using System.Text;
                  using System.Web.Services;
                  using Microsoft.SharePoint;
                  
                  namespace WebServiceDemo
                  {
                      public class MyCustomWebService : WebService
                      {
                          [WebMethod]
                          public string GetSiteListCount()
                          {
                              var web = SPContext.Current.Web;
                  
                              return (web.Title + " contains " +
                                  web.Lists.Count.ToString() + " lists.");
                          }
                      }
                  }
                  • Open Internet Explorer and navigate to your test SharePoint site. In the address bar add /_layouts/WebServiceDemo/MyCustomWebService.asmx and press Enter. You should see a service test page like the following.

                    image

                    • Click the GetSiteListCount link to navigate to a page that will allow you to test your service operation.

                      image

                      • Click invoke to test your service operation. A window should open that has XML contents that look something like this.

                        image

                        Creating a Sample Client Application

                        • In Visual Studio, click File | New | Project…
                        • In the New Project dialog, select the Visual C# node under Installed Templates.
                        • Select the Console Application template, set the Name to WebServiceClient and click OK.

                        image

                        Note: The next thing we need to do is add a reference to the service to create the service proxy class. Since we created an ASP.NET (ASMX) Web Service instead of a WCF Web Service we need to use the Add Web Reference dialog. The steps to do this may not be obvious if you do not know what to look for.

                        • In the Solution Explorer, right-click on your project and select Add Service Reference…
                        • In the Add Service Reference dialog, click the Advanced button.

                        image

                        • In the Service Reference Settings dialog, click the Add Web Reference… button

                        image

                        • In the Add Web Reference dialog, put the URL of your service (that is, the URL for your SharePoint site plus /_layouts/WebServiceDemo/MyCustomWebService.asmx ) in the URL bar and press Enter. You should see a page similar to the one shown below in the browser area of the form.
                        • Set the Web reference name to DemoProxy and click the Add Reference button.

                        image

                        • You should see a few changes in the Solution Explorer. The important one is the addition of the Web References and DemoProxy nodes. This indicates your service proxy has been created.

                        image

                        • Inside Program.cs, replace the code with the following:
                        using System;
                        using System.Collections.Generic;
                        using System.Linq;
                        using System.Text;
                        
                        namespace WebServiceClient
                        {
                            class Program
                            {
                                static void Main(string[] args)
                                {
                                    var proxy = new DemoProxy.MyCustomWebService();
                                    proxy.Url = "http://win7virtualbox/sites/demo/_layouts/WebServiceDemo/MyCustomWebService.asmx";
                                    proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
                        
                                    var response = proxy.GetSiteListCount();
                                    Console.WriteLine(response);
                                }
                            }
                        }

                        An explanation of the code is needed.

                        • The first line creates an instance of the service proxy class that was generated when we added the web reference.
                        • The second line sets the SharePoint context. I can call this service from the context of different SharePoint sites so it is this URL which determines the site name and list count that will be returned to me. As an example, the first of the following URLs calls the service from the Demo site while the latter calls it from the Sales site
                          • http://win7virtualbox/sites/demo/_layouts/WebServiceDemo/MyCustomWebService.asmx
                          • http://win7virtualbox/sites/sales/_layouts/WebServiceDemo/MyCustomWebService.asmx
                        • The third line sets the credentials of the caller. In this case it uses the credentials of the currently logged in Windows user.
                        • The fourth line calls the GetSiteListCount method and the last line writes out the response.

                        The final step is to test the client application.

                        • Press F5 to run the client application. You should see results similar to the following

                        image

                        How To Programmatically Read Best Bets for SharePoint 2010 Search

                        For one of the projects I’m working on, I needed to be able to iterate search best bets programmatically. I did a quick Google search and came up with a blog post by Stefan Goßner on the subject. Turns out Stefan’s post was for SharePoint 2007 and the code uses a type that has been obsoleted. A little more Googling and I came up with the code for SharePoint 2010.

                        Here’s the code for a simple Console app you can use as a starting point if you need to do something similar.  You’ll need to add a reference to Microsoft.SharePoint.dll and Microsoft.Office.Server.Search.dll (which can be found in the ISAPI folder under the SharePoint system root). You’ll also need to set the build target to Any CPU.

                        using System;
                        using System.Collections.Generic;
                        using System.Linq;
                        using System.Text;
                        using Microsoft.SharePoint;
                        using Microsoft.Office.Server.Search.Administration;
                        
                        namespace ConsoleApplication1
                        {
                            class Program
                            {
                                static void Main(string[] args)
                                {
                                    var site = new SPSite("<site collection url>");
                                    var proxy = (SearchServiceApplicationProxy)SearchServiceApplicationProxy.
                                        GetProxy(SPServiceContext.GetContext(site));
                                    var keywords = new Keywords(proxy, new Uri(site.Url));
                        
                                    foreach (Keyword keyword in keywords.AllKeywords)
                                    {
                                        Console.WriteLine(keyword.Term);
                                        foreach (BestBet bet in keyword.BestBets)
                                        {
                                            Console.WriteLine("\t{0} ({1})", bet.Title, bet.Url);
                                        }
                                    }
                                }
                            }
                        }
                        Posted by windsor | with no comments
                        Filed under: ,

                        Creating a SharePoint Site Page With Code-Behind Using Visual Studio 2010

                        A while ago I was reading Kirk Evans blog post on the subject of using code-behind in SharePoint 2010 site pages. I wanted to make sure things still worked the way they did in SharePoint 2007. Everything looked the same until I saw the part about updating the web.config file.

                        From Kirk’s blog post:

                        “The problem is that SharePoint has a setting that disallows server-side code with [site] pages.  This is a security feature that is good (you really don’t want end users to arbitrarily inject server-side code), but there may be cases where you are OK with some of your users having this capability.  For instance, you can have a page that is only visible to a small team within your enterprise, and one of the team members is very technical and wants to provide some custom code for SharePoint.  Party on, have fun with it, it saves my team from having to write that code.

                        To enable this scenario (and enable the Button_Click event handler in our code), we need to add an entry to web.config.  Knowing that we can’t just go to every front-end web server and make the modifications (any admin worth his salt should slap you silly for even thinking about hand-modifying multiple web.config files in a production farm), we should provide this as part of our solution.”

                        OK, I remember that in SharePoint 2007 you could add an entry in web.config to indicate the page parser should allow inline code for a page, but you didn’t have to do so. As long as the markup didn’t have anything indicating that code should run you were good. So I took Kirk’s example and modified it a bit so it would work without changes to the web.config.

                        In the markup, I removed the namespace imports, the CodeBehind attribute of the Page element, and the OnClick attribute of the Button element.

                        <%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
                        <%@ Register 
                            Tagprefix="SharePoint" 
                            Namespace="Microsoft.SharePoint.WebControls" 
                            Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
                        <%@ Register 
                            Tagprefix="Utilities" 
                            Namespace="Microsoft.SharePoint.Utilities" 
                            Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
                        <%@ Register 
                            Tagprefix="asp" 
                            Namespace="System.Web.UI" 
                            Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
                        <%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
                        
                        <%@ Page Language="C#" 
                            Inherits="SampleToDeployAPage.MyPageTemplate" 
                            Title="Testing This Page"
                            MasterPageFile="~masterurl/default.master" 
                            meta:progid="SharePoint.WebPartPage.Document" %>
                        
                        <asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
                          <asp:Button runat="server" ID="button1" Text="Click me" />
                          <asp:Label runat="server" ID="label1"/>
                        </asp:Content>

                        Of course, I needed to make changes to the code behind file to compensate for what I removed from the markup – but the changes were minor. All I needed to do was hookup the Button_Click method to the Click event of the Button. In WebForms, attaching event handlers is done in the Page_Init event.

                        using System;
                        using System.Collections.Generic;
                        using System.Linq;
                        using System.Text;
                        using Microsoft.SharePoint.WebControls;
                        using Microsoft.SharePoint.WebPartPages;
                        using System.Web.UI.WebControls;
                        
                        namespace SampleToDeployAPage
                        {
                            public class MyPageTemplate : WebPartPage
                            {
                                protected Button button1;
                                protected Label label1;
                        
                                protected void Page_Init(object sender, EventArgs e)
                                {
                                    button1.Click += new EventHandler(Button_Click);
                                }
                        
                                protected void Button_Click(object sender, EventArgs e)
                                {
                                    label1.Text = System.DateTime.Now.ToLongTimeString();
                                }
                            }
                        }

                        I kept everything else the same (minus the web.config changes of course), deployed, navigated to the page, clicked the button and SHAZAM! -  the date showed.

                        Posted by windsor | with no comments
                        Filed under: ,

                        Getting Started with SharePoint 2010 Development at DevTeach and Prairie DevCon

                        I’ll be doing a full-day post-conference session on SharePoint 2010 development at both DevTeach in Ottawa and Prairie DevCon in Winnipeg

                        This session is a day-long overview of development on the SharePoint 2010 platform. It is designed for those new to SharePoint, but will prove interesting to seasoned SharePoint developers looking to find out about the new features in 2010. We will begin with a look at foundational topics like Feature and Solutions Packages and then see how we can use the developer tooling in Visual Studio 2010 to quickly and effectively build customizations contained in these artifacts. Over the course of the day we will explore the SharePoint developer APIs, how to build custom web parts, working with SharePoint lists and libraries, and options to access data stored in SharePoint.

                        Understanding Features and Modules

                        • SharePoint 2010 architecture
                        • SharePoint terminology
                        • SharePoint development environment and tools
                        • Features and elements
                        • Solutions
                        • Deployment

                        Working with the Object Models

                        • Server object model
                        • Event handlers
                        • Client object model

                        Techniques to Access List data

                        • Object model
                        • CAML queries
                        • REST APIs (oData)
                        • LINQ to SharePoint

                        Building SharePoint Web Parts

                        • Web part infrastructure
                        • Visual web parts
                        • Persistent web part properties
                        • Web part connections

                        Introduction to SharePoint Workflows

                        • SharePoint workflow concepts
                        • Windows Workflow (WF) primer
                        • Building SharePoint workflows with Visual Studio 2010

                        Posted by windsor | with no comments

                        SharePoint for ASP.NET Developers–Recorded Session from DevLink

                        Here’s another recorded session from the DevLink conference.

                        SharePoint is an awesome tool. It allows you to build web sites, manage lists of data, collaborate on documents, and so much more – all done through a simple, easy to use, web interface. When you need to go beyond the built in capabilities of the product, SharePoint also provides a rich set of APIs to code against. This session is designed to introduce you to the foundational topics required to build customizations on the SharePoint platform. Specifically we will cover: Features, the solutions framework, the server object model, and building simple Web parts. This session will be valuable for those working with SharePoint 2007 or 2010.

                        SharePoint 2010 Client-Side Development with the JavaScript Client Object Model (JSOM) and jQuery – Recorded Session from DevLink

                        It’s been a busy month since DevLink but I finally have time to clear some tasks off my to-do list. One was to post this recording of my SharePoint 2010 Client-Side Development talk. I have a couple other partially edited session recordings. Hopefully it won't take a month to get those posted.


                        SharePoint Saturday: The Conference–Session Resources

                        Got back yesterday from SharePoint Saturday: The Conference. I met a lot of people I only knew electronically, learned a ton, and had a great time overall. That said, there were some issue that I guess you had to expect from such a large event being run by an all volunteer group.

                        “Even if we had prior experience in organizing 1-day SharePoint Saturday events, we underestimated the exponential amount of effort required to organize a 3-day event like this. As a result, there were some miscommunication issues, logistical inconsistencies and unmet expectations that was experienced by sponsors, speakers and attendees.” – Dux Raymond Sy from http://sp.meetdux.com/archive/2011/08/14/3-lessons-learned-from-spstcdc.aspx

                        It’ll be interesting to see if future multi-day SharePoint Saturday events are able to take the lessons learned and work them out.

                        Anyway, that’s for the future. For now, here are the links to the resources from my sessions:

                        SharePoint User Interface Development
                        One hour from the Developer 101 Workshop
                        Slides and demos:  http://bit.ly/oKWP66
                        Video recording:  http://vimeo.com/27724271

                        SharePoint for ASP.NET Developers
                        ​SharePoint is an awesome tool. It allows you to build web sites, manage lists of data, collaborate on documents, and so much more - all done through a simple, easy to use, web interface. When you need to go beyond the built in capabilities of the product, SharePoint also provides a rich set of APIs to code against. This session is designed to introduce you to the foundational topics required to build customizations on the SharePoint platform. Specifically we will cover: Features, the solutions framework, the server object model, and building simple Web parts. This session will be valuable for those working with SharePoint 2007 or 2010.
                        Slides and demos:  http://bit.ly/roZeFn

                        Integrating SharePoint 2010 and Visual Studio LightSwitch
                        Visual Studio LightSwitch is a tool that's designed to let power users build data-centric business applications for the desktop and cloud. The tooling takes care of code generation, data access and common infrastructure needs, allowing the application builder to focus on business logic. If enhanced functionality is required, developers can extend the application with custom .NET code. In terms of data access, LightSwitch applications can use many data sources including SharePoint 2010 list data. The tooling uses a combination of the client object model and the REST API, so the integration is rich and powerful. In this session, you'll see how to build LightSwitch applications that use data from SharePoint 2010.
                        Slides and demos:  http://bit.ly/rutyHM

                        Posted by windsor | with no comments

                        Enabling Intellisense for the JSOM and jQuery in SharePoint 2010

                        This blog post was requested by Mark Rackley (@mrackley) at his jQuery session at SharePoint Saturday New York. Mark mostly does middle-tier SharePoint development and he wanted to see what life was like inside the wonderful world of an Integrated Development Environment like Visual Studio.

                        I’d put together some content on enabling and using intellisense for the JavaScript client object model and jQuery in my Pluralsight On-demand course on the SharePoint 2010 Client Object Model so I took a few clips and put them together to make this video blog post. Big thanks to the people at Pluralsight for letting me use the content in this post.

                        Enabling Intellisense for the JSOM and jQuery in SharePoint 2010 from Rob Windsor on Vimeo.

                        Posted by windsor | with no comments

                        TVBUG Becomes North Toronto .NET User Group (NorthTorontoUG)

                        This is one of those good news/bad news posts.

                        The bad news (at least for me) is that, after more than 10 years, I’m stepping down as leader of the Toronto Visual Basic User Group. My work is taking me on the road more and more and I’m not in the city enough to be able to do the job.

                        The good news is that the group will continue on as the North Toronto .NET User Group. Big thanks to Luis Duran, Ryan Kajiura, Jack Lee, Obi Oberoi and Tony Cavaliere for stepping up and taking over the management of the group. Also, thanks to Graham Marko for helping out in an advisory role during the transition. Along with the name change will be a new website and a new URL. Jack Lee is working on getting everything up an running at NorthTorontoUG.com. Until the site is complete continue to visit tvbug.com to get information on the group and upcoming events.

                        Even though I’m no longer running the group I do plan to attend when I can. In fact, as I mentioned in a pervious post, I’ll be speaking at the September 8 meeting on Building Business Application with Visual Studio LightSwitch. I hope to see you there.

                        Posted by windsor | with no comments
                        Filed under: ,

                        Getting Started with SharePoint 2010 Development–Links and Resources

                        A few people have asked for advice on resources to help them get started with SharePoint development. Here are a few I like to suggest, add a comment if you have others.

                        Videos

                        Get Started Developing on SharePoint 2010

                        SharePoint 2010 Developer Training Course

                        How Do I Videos for Office Developers

                        Pluralsight On-demand Library (Subscription required)

                        Books

                        Inside Microsoft Windows SharePoint Services 3.0
                        This book is on SharePoint 2007 but I had to list it because it’s the book that helped me get started.

                        Inside Microsoft SharePoint 2010
                        The SharePoint 2010 version of the book above.

                        Beginning SharePoint 2010 Development

                        Professional Visual Basic 2010 and .NET 4
                        There’s only one chapter on SharePoint in this book but it was authored by yours truly so I had to list it.

                        Blogs

                        Microsoft SharePoint Team Blog

                        Other

                        Setting Up the Development Environment for SharePoint 2010 on Vista, Windows 7, and Windows Server 2008

                        StackExchange – SharePoint
                        A great place to ask SharePoint questions.

                        Posted by windsor | with no comments
                        Filed under: ,

                        Advanced SharePoint Web Part Development–Recorded Session from SPSNY

                        Got back from SharePoint Saturday New York yesterday afternoon. What a great event – the organizers and volunteers really went all out and everything went like clockwork.

                        I recorded my session and spent a good chunk of yesterday editing it so I could publish it today. If you have any questions or comments, please let me know.

                        Advanced SharePoint Web Part Development from Rob Windsor on Vimeo.

                        Web parts are the foundation of user interfaces in SharePoint. As a developer it's relatively easy (particularly with the visual web part in SharePoint 2010) to build something simple and get it deployed. But what do you do when you need to add editable properties or when you need to connect two web parts together? This fast-paced, demo-heavy session covers the more advanced aspects of building web parts for SharePoint 2007 and 2010. We’ll take a look at creating custom editor parts, building visual web parts, constructing connected Web parts, and making web parts asynchronous.

                        Posted by windsor | with no comments

                        Upcoming Community Events: Seven Talks in Five Cities

                        I spent the last few weeks getting settled in and working on the developer part of my new gig at Allin Consulting, now it’s time to work on the evangelist part. Over the next two months I’ll be speaking at events in five different cities. If you’re attending and want to have a chat you can ping me on Twitter (@robwindsor) or send me an email using the Contact link on the left side of the page. I hope to see you there.

                        SharePoint Saturday New York
                        July 30 in New York, NY
                        - Advanced SharePoint Web Part Development

                        SharePoint Saturday: The Conference
                        August 11 to 13 in Washington, DC
                        - SharePoint for ASP.NET Developers
                        - Integrating SharePoint 2010 with Visual Studio LightSwitch

                        DevLink
                        August 17 to 19 in Chatanooga, TN
                        - What’s New for Developers in SharePoint 2010
                        - Integrating SharePoint 2010 with Visual Studio LightSwitch

                        North Toronto .NET User Group
                        September 8 in Toronto, ON
                        - Building Business Applications with Visual Studio LightSwitch

                        SharePoint Saturday New Hampshire
                        September 24 in Manchester, NH
                        - SharePoint for ASP.NET Developers

                        Posted by windsor | with no comments

                        A New Chapter

                        I’m happy to announce that, starting July 1, I will be joining Allin Consulting as a Lead SharePoint Consultant. Allin (pronounced All-in, as in Texas Holdem) is located just North of Boston in Wakefield, MA.

                        Yes, this means I’m leaving ObjectSharp Consulting, with whom I’ve worked for the better part of the last six years. I’ve thoroughly enjoyed my time at ObjectSharp. I love that that company is so community focused and that everyone there, past and present, has a commitment to excellence for the customer.

                        OK then, why the move? Allin is a company very much like ObjectSharp – about the same size and with the same commitments to both the community and to their customers. The big difference is that they specialize in SharePoint and that’s where I want to specialize as well. I still enjoy doing .NET assignments but I feel I can make more of an impact for both the community and for clients doing SharePoint. SharePoint today feels to me like .NET did in 2002/2003. There are so many opportunities to help the developer community and that, in turn, always means opportunities for me to learn as well.

                        Another aspect of this change is that I will be increasing my involvement in community. I’ll be blogging more and be spending more time at community events and conferences - particularly SharePoint Saturdays. Speaking of community, a sad component of the change is that I am going to have to step down as the leader of the The North of Toronto .NET User Group (which many of you know as the Toronto Visual Basic User Group). I was happy to run the group for 10.5 years, I hope that I’ll be able to find someone to take over the reigns.

                        The rest of the details will have to wait for others posts – mostly because we are still working them out. I know I’ll be spending some time in Boston, some time in Toronto, and some time in other places. Wherever I am, if you’re close by feel free to ping me on Twitter and we can grab a beverage and talk about SharePoint (and maybe other geek stuff as well).

                        Posted by windsor | 4 comment(s)

                        Custom Content Types and Inherits in SharePoint 2010

                        SharePoint 2010 adds an attribute named Inherits which you can use when defining custom content types in CAML. When you create a content type in Visual Studio 2010, this attribute is included and it’s set to TRUE. The description of the Inherits attribute in the SDK reads:

                        Optional Boolean. The value of this attribute determines whether the content type inherits fields from its parent content type when it is created.

                        If Inherits is TRUE, the child content type inherits all fields that are in the parent, including fields that users have added.

                        If Inherits is FALSE or absent and the parent content type is a built-in type, the child content type inherits only the fields that were in the parent content type when SharePoint Foundation was installed. The child content type does not have any fields that users have added to the parent content type.

                        If Inherits is FALSE or absent and the parent content type was provisioned by a sandboxed solution, the child does not inherit any fields from the parent.

                        So it would seem that this attribute controls which fields a content type will inherit from its parent. That it does, although likely not in the way that you would expect. It also has other effects that are not immediately obvious. Let’s take a look at the following example in some different scenarios:

                        	
                        <ContentType ID="0x0104007570511f066f4032b78e1041afc72fb7"
                        			  Name="SharePointProject5 - ContentType1"
                        			  Group="Custom Content Types"
                        			  Description="My Content Type"
                        			  Inherits="?????"
                        			  Version="0">
                          <FieldRefs>
                        	<FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" DisplayName="Announcement" Required="TRUE" />
                        	<FieldRef ID="{d2311440-1ed6-46ea-b46d-daa643dc3886}" Name="PercentComplete" />
                          </FieldRefs>
                        </ContentType>
                        

                        Here, we are creating a custom content type that inherits from Announcement. It changes the display name of the Title field to Announcement and adds a field for percent complete (I know, a little contrived, but it is just an example). Now lets look at the scenarios:

                        Farm Solution with Inherits set to False 
                        This works as described above. The behavior in this case, at least as far as I can tell, is the same as it was in SharePoint 2007.

                        ContentType01

                        Sandboxed Solution with Inherits set to False
                        In this case, although the parent content type is recognized as Announcement, none of the fields come over unless they are specifically included as a FieldRef in the child type.

                        ContentType03

                        Farm or Sandboxed Solution with Inherits set to True
                        In these cases the percent complete field is added but the changes to the properties of the Title field are ignored. In fact, changes to any of the properties of fields inherited from the base type will be ignored. Also, any attempts to remove fields inherited from the base type will be ignored. As far as I can tell, the only thing you can do when Inherits is true is add additional fields to the type – everything else is ignored.

                        ContentType02

                        One final note. The concept of Inherits and the behaviors described above only apply when creating content types using CAML. Creating content types with code, whether it’s a full trust or sandboxed solution, works the same as it did in SharePoint 2007.

                        Posted by windsor | with no comments
                        Filed under: ,

                        Toronto Code Camp 2010 Resources – Building Apps with ASP.NET MVC

                        Thanks to all of you who came out to the Code Camp and kudos to the Chris Dufour and the volunteers for running a great event.

                        Building Applications with ASP.NET MVC
                        ASP.NET MVC represents an alternative framework for developing web applications on top of the ASP.NET runtime. It provides strong support for testing, extensibility and routing, giving developers control over their code, markup and URIs. This session will introduce the basic concepts and conventions of an MVC application and explain how to build applications using the pattern.

                        Download the demo application built during the session.

                        For more on the topic, check out these recorded presentations by Scott Guthrie and Scott Hanselman.

                        Scott Guthrie on ASP.NET MVC 2 (using the Beta) – Part 1 of 2

                        Scott Guthrie on ASP.NET MVC 2 (using the Beta) – Part 2 of 2

                        Scott Hanselman on ASP.NET MVC 2 at DevDays 2010

                        Technorati Tags:
                        Posted by windsor | with no comments
                        Filed under: , ,

                        Frequently Asked Questions about the Visual Studio 2010 Tools for SharePoint

                        I've seen several questions about the Visual Studio 2010 tools for SharePoint development coming up quite frequently. I’ll use this blog post to compile them along with answers and links to associated resources:

                        Question: Can I use the Visual Studio 2010 tools for SharePoint to develop against a remote server?

                        No. The tools are designed to work against a local SharePoint server only. In fact, if you try to create a new SharePoint project without SharePoint deployed locally you will see this dialog:

                        Question: Can I use the Visual Studio 2010 tools for SharePoint to develop for SharePoint 2007?

                        No. Well, not really. The artifacts generated by the Visual Studio 2010 tools (e.g. XML documents, webpart files, user controls) are generally compatible with SharePoint 2007. So, you could create an element (e.g. a Visual Web Part) using the new tools and copy the generated files over to another project. You can also build SharePoint 2007 projects in Visual Studio 2010 in the same way you would in Visual Studio 2008 (i.e. using a Class Library). The people from the WSPBuilder project have a Beta version that works with Visual Studio 2010 that can target both SharePoint 2010 and SharePoint 2007 (http://keutmann.blogspot.com/2009/12/wspbuilder-2010-beta.html).

                        Question (related to the one above): Can I use Visual Web Parts developed with Visual Studio 2010 in SharePoint 2007?

                        The answer is pretty much the same as the one above. However, you can easily employ the same strategy used by the Visual Studio 2010 tools to build Visual Web Parts for SharePoint 2007 in Visual Studio 2008. Check out this video for step-by-step instructions:

                        Question: Can I use the visual designer when developing application, site, or master pages?

                        No. Visual Studio 2010 does not have designer support for anything other than Visual Web Parts. You can use SharePoint Designer to prototype a page and then put the generated markup into a page in your Visual Studio project.

                        Posted by windsor | with no comments
                        Filed under: ,

                        DevTeach 2010 – Lap Around ASP.NET 4 Session Materials

                        Abstract:
                        There are a significant number of changes for web developers in Visual Studio 2010 and .NET 4. Visual Studio offers new project templates, markup snippets and integrated web deployment features. WebForms adds routing, greater control of client identifiers, and easy integration between the data controls and dynamic data. ASP.NET AJAX gets a new name and adds client templates, the observer pattern, and jQuery out-of-the-box. Finally ASP.NET MVC is getting a whole new version. In this demo heavy session we will cover and many of these new features as time allows.

                        Slides and Demos:
                        http://cid-b810a8a4579bd670.skydrive.live.com/browse.aspx/Talks/2010/DevTeach/Lap%20Around%20ASP.NET%204

                        Resources:
                        VS 2010 and .NET 4 Web Development Part 1 with Scott Guthrie
                        VS 2010 and .NET 4 Web Development Part 2 with Scott Guthrie
                        Channel 9 – The 10-4 Show

                        Posted by windsor | with no comments

                        Toronto SharePoint Camp – March 20

                        The third annual Toronto SharePoint Camp will deliver over 20 sessions by the best Canadian and international SharePoint experts on a wealth of topics. Whether you're a developer, server administrator, architect, power user, or business sponsor; whether you're learning about SharePoint for the first time or a seasoned pro; whether you're migrating, developing, designing, or planning; this is the event for you!

                        FREE Registration includes lunch. Walk-up registration stays free, but to control waste we will charge $5 per lunch if you're not pre-registered. If you plan to be there, register today!

                        Thanks to our wonderful sponsors for keeping the Toronto SharePoint Camp free for all: Microsoft Canada, KwizCom, Infusion Development, Navantis, and Marlabs.

                        To register, please visit:  https://www.clicktoattend.com/invitation.aspx?code=145978

                        Posted by windsor | with no comments

                        Installing SharePoint 2010 RTM

                        I installed SharePoint 2010 on Windows 7 and Windows Server 2008 recently. There were several resources on the web to use as a guide, I found this one to be the best:

                        Setting Up the Development Environment for SharePoint Server

                        There are a couple main points you need to be aware of:

                        • The setup contains a config file that must be edited to allow SharePoint to be installed on a Windows 7 or Vista
                        • There are several prerequisites required before you install
                        • There are a few hotfixes required after the install but before running the SharePoint Configuration Wizard
                        • Install Visual Studio after you install SharePoint (this isn’t in the guide)

                         

                        Technorati Tags:

                         

                        Posted by windsor | with no comments
                        Filed under: ,

                        How LINQ Works in Visual Basic 9.0

                        I recently did a talk at DevLink that covered the language enhancements in VB 9.0 and C# 3.0 that support LINQ.  I was looking around Channel 9 last night and I noticed that Beth Massi and Johnathan Aneja from the VB team had a video covering the same material. It only covers VB, but almost of of the language enhancements they discuss were also implemented in C#.

                        LINQ Language Deep Dive with Visual Studio 2008
                        Ever wonder what really happens when you write a simple LINQ query? A lot of new language features went into the compilers in Visual Studio 2008 to make LINQ work. In this interview I sit down with Jonathan Aneja, a Program Manager on the Visual Basic Compiler team, who dives deep into these features like Type Inference, Anonymous Types, Lambda Expressions, Expressions Trees, and more. He explains what's actually happening behind the scenes and all the work the compiler is doing for you when you write a LINQ query.

                        Capture

                        Posted by windsor | with no comments
                        Filed under: , , ,
                        More Posts Next page »