Archive for May, 2011

ASP.NET: Create user Control

May 24, 2011 Leave a comment

In this article, we will be building a simple User Control to demonstrate how a ASP.NET User Control can be added into a ASPX page.


Assuming that you created an Empty Web Application from Visual Studio, you now create a new User Control by right-click on your web application > Add > New Item and name it MyUserControl.ascx. Then click Add.


Now, you have created your User Control. Now, lets put in some text so that we can see it in the web page later.


Next, we will add this User Control into our ASPX web page. First, you have to register your User Control on the top of your page, under the @Page declaration. You should add the @Register declaration like below.


<%@ Register src="UserControl/MyUserControl.ascx" tagname="MyUserControl" tagprefix="uc1" %>


The “src” property should be pointing to where your ASCX file is located. Then you can name the “tagname” and “tagprefix” property. By default, the “tagname” will be your User Control file name, and the “tagprefix” will be “uc1” if you are adding the first User Control in the page.


Next, you add the control into your page like how you add a Button  or Label into your webpage. Add the following code into the Body.


<uc1:MyUserControl ID="MyUserControl1" runat="server" />


Your ASPX page code should look like the following.


Now, save and run your code. You will see that your User Control is loaded into the web page. You have just successfully added a custom User Control into your web page.

Categories: ASP.NET Tags: , ,

SharePoint (Beginner) : FileNotFoundException

May 10, 2011 2 comments

For a beginner developer in SharePoint 2010 (with no experience with older version of SharePoint), you might be coding some simple “Hello World!” as your first SharePoint application. You might create a new Windows Console Application Project from Visual Studio and copy some sample codes from somewhere and try to run it. So you hit the magical F5 button and your project compiles successfully. However, when the program tries to run, Visual Studio throws you an FileNotFoundException, like the image below.

SharePoint 2010: FileNotFoundException

SharePoint 2010: FileNotFoundException

You then might be searching for codes error, is the SharePoint service running, & etc and found out that everything is running fine. So what’s the error?

The solution to this is to check your project platform target. By default, Visual Studio platform target is 32-bit (x86). Note that SharePoint 2010 ONLY runs on a 64-bit (x64) platform. So, you couldn’t run a 32-bit program on a 64-bit SharePoint Server. Now, to change your project platform to 64-bit, follow the steps below:

  1. Right-click on your Project in the Solution Explorer pane in Visual Studio and select Propertise
  2. Go to the Build tab and select x64 OR Any CPU
  3. Save changes, rebuild and run your program again.

SharePoint 2010: FileNotFoundException - 2

MSDN Malaysia: Orchard on the Cloud contest

Hi everyone,

MSDN is having a great contest with great prizes to be won for 5 weeks. Check it out!


What is this contest about?

We are looking out for the best Orchard on the Windows Azure platform, literally. Orchard CMS is a free, open source content management system that allows users to rapidly create web sites on the Microsoft ASP.NET platform. It is built on a flexible extensibility framework that enables developers and customizers to provide additional functionality through extensions and themes.


What attractive prizes do I stand to win?

We will be picking the best Orchard on a weekly basis during the duration of this contest. The best Orchards stand to win the following:

Week 1 Arc Touch Mouse + Arc Keyboard
Week 2

Wireless Xbox controller

Week 3 Crumpler Bag
Week 4

Microsoft Sidewinder X3 + X4 (mouse + keyboard)

Week 5 USB 3.0 External Hard Disk Drive

And everyone who enters will also receive a RM10 Starbucks Gift Voucher*!

Pre-requisite: Get your free Windows Azure Pass. (Step-by-step guide here)

HOWTO: Orchard CMS on Windows Azure

Step 1: Go to Orchard CMS web application page on Windows Web App Gallery

Step 2: Install Orchard CMS on your local computer, and explore what and how to customize.

Step 3: Use your creative imagination and innovation to customize your Orchard website to the best-looking Orchard site. You wouldn’t want it to look as plain as the following:

Step 4: Once you have tested your customized Orchard website on your local machine, it’s time to deploy it on Windows Azure platform. Full tutorial can be found here.

Step 5: Report your customized Orchard CMS website by telling us its URL on Windows Azure. For example,