Surendra Sharma

Surendra Sharma

Search This Blog

Friday, October 31, 2014

How to map Visual Studio web project to Sitecore

Once you installed Sitecore then next step is to create and map your Visual Studio Web project to Sitecore.

It’s good to install software in sequence of IIS, SQL Server, Visual Studio and then finally Sitecore.

For this tutorial we will create Welcome page in Visual Studio and show Welcome <Employee Name> message where Employee Name should retrieve from Sitecore Content item. Final screen should look like

My Sitecore instance is running at “C:\inetpub\wwwroot\NewInstance2\Website” and I will create my visual studio project at “D:\MyTestApp”.

So we have all the necessary details. Let’s do mapping now.

Here are steps to map your project with Sitecore.

1.    Create ASP.NET Empty Web Application project in C# having name like “SitecoreWebApp” as below

2.    Delete Web.config file from newly created project.
Add folders like “layouts”, “sublayouts”, “upload” and “xml” to this application.
Add “welcomepage.aspx” page in layouts folder.
Copy “Sitecore.Kernel.dll” from Sitecore instance [i.e. from C:\inetpub\wwwroot\NewInstance2\Website\bin] to project bin directory [i.e. to D:\MyTestApp\SitecoreWebApp\SitecoreWebApp\bin] through file system.
Add reference of this “Sitecore.Kernel.dll” to current project and set its property CopyLocal = false.
After all these steps your solution should look like this

3.    Login to Sitecore and create “Employee” template as below

4.    Also create standard values for this template by selecting Employee Template -> Select Builder Options Menu -> Click Standard Values as below

5.    Enter token in Employee Name field as “$name” so that content item name should filled by default as below

6.    Create Layout having name “welcomepage” as below

7.    Create content item with name “Surendra Sharma” as below. Check Employee Name field filled automatically as per the item name.

8.    Our content is ready but we need layout to display this information. So map this content with layout by selecting content item “Surendra Sharma” -> Presentation Menu menu -> Details -> Click Edit link from Default section -> Select Layout -> Select “Layouts\welcomepage” as below

9.    Now go to Visual Studio project and design and code “welcomepage.aspx” page as below

10. Till this step we mapped everything. It’s time to publish our Web application from Visual Studio. So right click your project from Solution Explorer and select Publish. Create profile and select publish method as “File System”. Select Target Location as your Sitecore instance website folder. In my case it is “C:\inetpub\wwwroot\NewInstance2\Website” as shown below

11. In next step select Release configuration only and uncheck Delete checkbox as shown below

12. After successful publishing, we can Preview the content item. So select “Surendra Sharma” from content tree -> Publish Menu -> select Preview as shown below

13. Your browser should show screen like this

14. Bazinga!!!! Congrats, if you are reading this line, you successfully mapped your project with Sitecore.

Please leave your comments or share this guide if it’s useful for you.

Thursday, October 30, 2014

How to install multiple web instances of Sitecore on single machine

If you want to work on multiple Sitecore projects then it’s a tricky situation to install and run multiple Sitecore instances on the same machine.

If you don’t know how to install Sitecore, then please refer my previous article on it from here.

First install as many sitecore instances you want. At my machine I installed 3 instances of Sitecore as NewInstance1, NewInstance2 and NewInstance3.

I had used same License.xml file during installation of all instances.

After installation, my IIS and SQL Server should look like this

For each instance, there are 3 databases.

·         If you want to browse and run all instances at the same time then there must be valid entry in “hosts” file at “C:\Windows\System32\drivers\etc” for each instance as shown below

If you did not find any such entry in Hosts file then make it manually.

Please leave your comments or share this tip if it’s useful for you.

Wednesday, October 29, 2014

Installation guide for Sitecore through Setup

This article refer to installation of Sitecore by using Setup.

Before installing Sitecore, make sure you installed IIS, SQL Server and Visual Studio respectively.

You must have Sitecore Setup EXE like “Sitecore 7.2 rev. xxxxxx.exe” and licence.xml file.
Here is complete guide 

·         Double click on Sitecore Setup EXE. Click Next on Welcome wizard.

·         Select ‘New Instance’

·         Accept license agreement.

·         Select Complete installation type.

·         Enter Instance Name

·         Browse License file.

·         Enter SQL Server credentials. This steps should create three database with prefix NewInstance3 like “NewInstance3Sitecore_Web”.
If you want to change prefix then select “Advanced…” button in the same screen and change “Database Prefix”.

·         Select sitecore installation path.

·         Select Web Site name that should be created in IIS.

·         Finally click Install and wait for setup to proceed.

·         If you get this screen then congratulation you installed sitecore successfully. Check Launch Sitecore box.

·         Once you click on Finish button, you should get

·         If you are not getting welcome sitecore screen then check entry in “hosts” file at “C:\Windows\System32\drivers\etc”. There must be entry for new instance like “            NewInstance3”. If any such entry is not found then then do it manually.

Please leave your comments or share this guide if it’s useful for you.

Monday, October 27, 2014

How to inherit templates in Sitecore

During working with templates in Sitecore, there are situations when you want to implement inheritance mechanism. So here is simple way to do it.

Suppose we want to create “Slide” template having header and footer. In programming terms every Slide should get inherit from Header and Footer. So we will create two template like “Header” and “Footer” as below

After header and footer, we will create “Slide” template as below

As every slide contains header and footer, so let’s assign “Header” and “Footer” template.
Select “Slide” template -> Click on Content tab -> Assign “Header” and “Footer” template from “__Base Template” fields as below

You can verify this association from “Inheritance” Tab of “Slide” Template as below

Now whenever you will create content item of “Slide” template, you will get fields with sections of Footer, Header and Slide and as below

Please leave your comments or share this technique if it’s useful for you.

Monday, October 6, 2014

How to convert column values in date in Excel

Recently I come across with interesting situation.

My friend called me and ask for technical help. I thought he wants to ask something in .NET or SQL Server as I am working with these technologies. But my surprise he asked me something interesting question related with Microsoft Excel.

Here is the problem

His COBOL program is generating excel file which contains month, day and year columns. He wants complete date column by applying just the excel formula in generated sheet.

Solution :

I had not any Internet connection at that time so I opened Excel in my Laptop.

Just created with text column for Month, day, Year and Final date in blank Excel file and started to play with available functions in Excel.

Microsoft already paid attention with these kind of situation by providing Date() function.


=DATE(year, month, day)

Just pass cell details in parameters and you will get the desired result as shown below.


= DATE(E3, C3, D3)

Please leave your comments or share this tip if it’s useful for you.