How to create a web part containing ASP.NET AJAX-enabled user control in SharePoint 2010

There are existing guides to creating a web part that hosts a user control and others on creating an ASP.NET AJAX-enabled web part. Here I’ll discuss how to create a web part that combines both features. With the user control, you can perform complex layout more easily using the visual designer. And of course, with ASP.NET AJAX you can eliminate full-page postbacks and provide users with a smoother browsing experience.

The walkthrough includes a SoftArtisans.Tutorial.AjaxWebPart for SharePoint 2010 (it can be made to work for SharePoint 2007 with little modification).

SharePoint and ASP.NET AJAX
With SharePoint 2007, the first step would be to configure SharePoint to use ASP.NET AJAX. Fortunately, SharePoint 2010 is already enabled for ASP.NET AJAX, so you can avoid performing error-prone surgery on Web.config.

Step 1: Creating the project

While there are SharePoint project templates, I prefer to use a basic project template for the maximum control and flexibility. It is also more instructive to delve into the nuts and bolts rather than have everything generated for you. Continue reading How to create a web part containing ASP.NET AJAX-enabled user control in SharePoint 2010

The 9 Things a B2B Should Be Doing on Twitter

Twitter is closing in on its 5thanniversary, which is kinda old in contempo-startup world.  Even though I jumped on the blogging bandwagon fairly early, and the Tumblr bandwagon almost immediately, I spent about the first four years of Twitter’s existence scoffing at it. I was one of the myriad “twitter-is-for-c-list-celebutards-oggling-eachothers’-french-toast-stix” kvetchers. And then, I graduated, got a job and realized that, as far as the B2B world is concerned, Twitter is maybe the best thing since trade shows.

Why? Because it humanizes a sector that is inherently barricaded. Those French toast stix pix? Humanizing. Because B2B employees eat breakfast too, yo.

But seriously, what Twitter provides is a direct path to both the direct customer and the indirect end-user.  It provides a steady and constantly updated stream of industry news, gossip and watercooler fodder. It provides guppies with a way to swim with sharks. It’s like a virtual bar crawl where cred isn’t a credential. Continue reading The 9 Things a B2B Should Be Doing on Twitter

How to create a dynamic Reporting Services Shared Data Source Using Linked Servers

When using SQL Server Reporting Services (SSRS), wouldn’t it be nice to be able to specify the data source at run time? For example, you could deploy a report on a single Report Server, but have the ability to retrieve data from any database on any server. Without a dynamic data source, you would have to deploy multiple instances of the report, one for each database server you want to use. Additionally, if you are using stored procedures, you must also duplicate them on each database server.

SSRS already allows for a dynamic data source through an expression-based connection string. The main limitation is that an expression-based connection string can only be used with an embedded data source; i.e., one that is contained in the report definition. You cannot use it with a shared data source. However, a shared data source offers advantages over an embedded data source and is often a necessity. Imagine having to modify the data source for hundreds of reports. With an embedded data source you would have to edit every report, while with a shared data source you could do so in just one place.

This post discusses a solution that lets you specify the database server at run time, while still being able to use a shared data source. The solution uses linked servers. A linked server is essentially an alias for a remote server on a local server. Once defined, a linked server allows you to execute queries on the remote server locally. This solution consists of the following steps: Continue reading How to create a dynamic Reporting Services Shared Data Source Using Linked Servers

Introduction to Rhino Mocks

[image via Brian Schroer]
Because mocking objects is awesome, here is a quick introduction to Rhino Mocks so that we can use it in any C# code.

What is a mock object?

The mock object is a very light weight object where you can simply define what to return when a given method is called with a given parameter. You may at some point want to write a unit test on an object that depends on another class. To avoid this dependecy, you mock out that class and replace it with a mock object. So, for example, if I’m testing an aggregate class:

// combines a list of numbers using a given operator.
// e.g. if your operator is addition, and you pass 2,3,4 to the aggregate method,
// it will return 2+3+4=9
class Aggregator
{
    Aggregator(IOperation op) {...}
    double Aggregate(out string text, params double[] numbers) {...}
}
// an operator such as addition or subtraction or a random number generator.
interface IOperator
{
    string DisplayText {get; set;}
    double Operate(double a, double b);
}

Mocks give you the freedom from depending on an operator to perform correctly in order to have your unit tests for the aggregator class to pass. Continue reading Introduction to Rhino Mocks

Considerations When Using View in CAML Search

I recently worked on a web part which processes test scores for students. Test scores are stored in a list, organized by course and by user. The web part should retrieve the test scores for the logged in user, then the user’s score for each course. A previous implementation used a view, My Scores, which showed test scores for the logged in user by defining a filter, “Username is equal to [Me]”.

It occurred to me to retrieve a user’s test score for a course by performing a CAML search on the My Scores view. Typically, when searching a list using a CAML query, you can do something like this:

SPQuery query = new SPQuery();
query.Query = <query for course>;
results = list.GetItems(query);

There is an overloaded version of the SPQuery constructor that takes an SPView. Additionally, SPList.GetItems has an overloaded version that also takes an SPView. Given the availability of the SPView parameter, I was tempted to perform the CAML search on the My Scores view by doing the following: Continue reading Considerations When Using View in CAML Search

5 Resume Dos and Don’ts: the Good, the Bad and the Ugly

Keep in mind that most people in the hiring process, especially in Human Resources, review somewhere close to a googol of resumes in their career. Hyperbole perhaps, but hopefully you understand the extent of the sheer numbers you are up against when you apply for any position. Needless to say, if your resume does not pass the first review, you are highly unlikely to get that position.

Most HR staff, myself included, look at resumes and quickly put the bits of information contained therein into one of three categories:

  • Things that qualify you for the position
  • Things that tend to neither help nor detract from your candidacy
  • Things that disqualify you for the position or otherwise raise a red flag

Time and time again, the same types of mistakes occur. Since categorization seems to be a sub-theme of this blog, here is my list of the types of mistakes to avoid and the good, the bad and the ugly. Caveat — I’ve participated in many resume critique workshops at colleges helping students perfect a resume — one thing that I have noticed is that each college’s idea of a perfect resume differs. For example, one college insists that you have an “Objective” statement and one college insists that you DO NOT have an ‘Objective” statement.  This segues into #1:

1) Poor or vague objective statement – If you do put an objective statement, make it clear, specific and informative. This is not a place for buzzwords or overly broad statements. Continue reading 5 Resume Dos and Don’ts: the Good, the Bad and the Ugly

Setting An Automated BlackBerry Test Environment Against A Real BES: A Story Of Failure

We wanted to set up an automated testing environment for the Blackberry in which we could test against multiple versions of a real BES. We have a pretty solid framework for automated testing of OfficeWriter, and since it proved itself to be very beneficial, we decided to try to do the same for our BlackBerry product. We already have a framework in place which runs automated tests on the simulator using the MDS simulator. We even extended this framework to run against an actual SharePoint server, although that’s a topic for another blog post. So, if precedence counts for anything, setting up an automated test environment for BlackBerry should have been a snap, right? Wrong. Here I wish to describe the path we walked down as we tried to set up a test environment that would run automatically against a real BES.

Setup

In order for a simulator to run against a real BES, it needs to connect to Desktop Manager, so we have set up two (Windows 7 64bit) virtual machines, each with a simulator and a Desktop Manager set up with a user provisioned through BES – one for BES 4 and one for BES 5. In order to automatically access and control these machines we chose to use PsExec from our Ant script using the exec tag and passing in the needed arguments. So, for example the followings, as part of an Ant target, will restart MyRemoteMachine using PsExec: Continue reading Setting An Automated BlackBerry Test Environment Against A Real BES: A Story Of Failure

Women in Technology: A Call for Obsoletion

Tomorrow, I’m going to be on a panel discussion about women in technology, moderated by the very inspirational, crater-shirt-rocking Karen Lopez. The discussion’s key focus is gender disparity in IT, the why and how and how much. And it got me thinking, both about women in technology, and about Women in Technology, and how the lack of the former is the why of the latter.

In 1991, women held 36% of all computer-related jobs in this country. By 2008, that percentage had dropped to 25. Of the few women who do go into the tech industry, even fewer stay more than a decade. According to a report by Dr. Catherine Ashcroft and Sarah Blithe from the National Center for Women & Information Technology:

“Forty-one percent of women leave technology companies after 10 years of experience, compared to only 17 percent of men…Fifty-six percent of women in technology companies leave their organizations at the mid-level point (10-20 years) in their careers.”

So that’s the what. But why? Knowing how to program might not always garner you an iPad and a $10k signing bonus, but it does, and has ensured relatively high pay for relatively low stress (in CareerCast’s annual list of best jobs, “Software Engineer” is always in the top 10). So why the dearth? Continue reading Women in Technology: A Call for Obsoletion

Using SQLite in BlackBerry Applications

We recently decided to add some basic persistence to Pylon, our latest mobile application for accessing SharePoint. Nothing complicated, just logging levels, username and SharePoint URI.

We decided to use SQLite for persistence instead of the BlackBerry Persistent Store  because of our previous experiences with the latter – where we encountered some stability issues such as the insidious 523 error which requires removing the battery to fix. We were also looking for an approach that would be more compatible when we port our application to iOS and Android.

The BlackBerry code samples for basic SQLite operations are straight-forward: http://docs.blackberry.com/en/developers/deliverables/8682/Code_samples_702046_11.jsp

However after basing our code on the samples we did run into a couple of issues.

SQLite not working on some phones – “Error: file system not ready”

The first issue we ran into was that the database simply didn’t work for certain phones. The confusing thing was that it wasn’t even consistent for phones of the same model.

It turns out the key was this line in the BlackBerry documentation:

“You can create database files in eMMC memory, on devices that support it, by specifying the corresponding file system path.”

Our application would use an SD Card if there was one, otherwise we would use device memory. If the device didn’t have an SD Card AND it didn’t have eMMC memory then we would get a “file system not ready” error when creating a database.

Phones that support SQLite DB in device memory (eMMC)

  • Torch
  • Storm 2

Phones that DON’T support SQLite DB in devicememory

  • Bold
  • Curve

Even with an SD Card, SQLite might not work if Media Card Support is turned off or if the phone is tethered to a computer and Mass Storage Mode is turned ON.

Intermittent Error – “Error: File system error (12)”

Another error we ran into was that sometimes opening the database soon after reading or writing to it would fail with the error “File system error (12)”. Just for testing I added code that would try to open the database a second time in case of failure after sleeping 100 milliseconds. This second attempt to open the database would always succeed.

Looking for “File system error (12)” online I found a few instances that were determined to be caused by bad queries or by failing to close the database or a SQL Statement. However the exact same query that worked most of the time was being called when the error would occur and after reviewing the code we determined that all databases and SQL statements were being correctly closed.

It turns out that we were following the BlackBerry examples a little too closely and opening/closing the database for every read/write operation. The overhead of this meant that the database wasn’t ready to be opened in time for the next operation.

We fixed the problem by only opening the database once the first time and then reusing that handle all subsequent times until we close the database on application exit.

Around the World in 63 Days: a SharePoint Vacation

We’re officially three days into spring, but as any New Englander knows, “official” is code for “probably not going to happen,” or “snow falling on crocuses.” Which is what’s currently happening, by the way. There are two time-tested ways of dealing with late-onset SAD:

1)Drown it in liquid courage. Nowhere’s warmer than an Irish bar two hours after a Dropkick Murphys’ concert!

2)Nurse it under a palm tree.

Now, if you’re type 2, but a full-on vacation isn’t really in the cards, but you happen to work with SharePoint, you’re in luck.* These next few months are filled with top-notch SharePoint conferences in locales warm (Vegas), historic (London) and warm, historic and exotic (Lima). Here are 7 that caught my eye—if I’ve left any out, let me know in the comments! Continue reading Around the World in 63 Days: a SharePoint Vacation

Blogged