Wednesday, November 19, 2014

Step by Step guide to create First PDF report with ADOBE Pro and iTextSharp -- .NET

Recently I had to work on a reporting module for Mobile application. I used iTextSharp to write wrapper class which was responsible for creating PDF files on the fly. The plan was to create PDF forms from Adbobe Acrobat Pro and generate PDF reports using the iTextSharp and my wraper class. My wrapper class takes PDF Template path, Simple Modal object (Just having values to print on PDF) and the output PDF path as input and generate PDF report. Let us see in more detail.

First Install NuGet Package, iTextSharp

Create PDF form 

First create a mock up of a report in the word document,


Reflection: Dynamically reading Object Properties and Calling Methods -- .NET


Introduction

In the .NET Framework, every program is compiled into an assembly containing metadata which has information of assembly behavior and structure. Reflection in .NET is used to observe and change the behavior of any object which means you can read read metadata of an object through reflection.

Current sample is going to describe following features of Reflection,
  1. Object properties and their datatypes.
  2. Call object methods dynamically. 
The first thing to use reflection in your project is, include the reflection namespace,

using System.Reflection;

Sunday, September 28, 2014

Opening InfoPath Form in Modal Dialog

Question 


How to open InfoPath New and Edit forms in the Modal dialog?


Answer


Let us start with new fresh InfoPath Library. Create an InfoPath Library and call it "AccordionForms". The path of library would be like,


Let us examine new and edit form URLs.


New InfoPath Form:


If you click on the new item link, it would redirect to URL,


Wednesday, September 24, 2014

Create Info Path Accordion (Show Hide Section)

Previously i worked on the project which used InfoPath form. The Form had many sections and each section had scrolling and lot of data. I needed to introduce accordion in the form. I needed to add buttons to show hide any section of the form so that user can focus on what is required. InfoPath is different than the normal JQuery accordion where you can hide or show any thing based on script or just CSS. In InfoPath you need to add behavior and Rules for each button and section which we want to hide or we want to use as changing behavior or variable. Following is the how i achieved it,
1- First thing first, add two picture buttons (Having up and down pictures).  

2- Add Boolean variable ESShow and set its default value as 0 if you want to hide section when InfoPath form loads otherwise set its default value 1.


Content Editor Web Part Example (Writing Custom Web Part

The Content Editor Web Part (CEWP) allows you to add text, html, JQuery or styles to a SharePoint page. It is great to use this if you,

  1. Are good in JQuery or Javascript.
  2. Want to use Web Services, REST API (Introduced in SharePoint 2013) or ECMA script.
  3. Need One or two pages of customization and do not want to touch Visual Studio and going through process of uploading solutions.
  4. Do not have deployment permissions on Central Administration.

Add a Web Part to a page


1. From a page, in the ribbon, click the Page tab, and then click the Edit command.

Image: Edit command of the Edit tab

Display Parent web InfoPath form in child web InfoPath Form Web part

Problem

Yesterday i faced an issue while displaying Info Path form in the web part. My task was to show the Info Path form in the child web but actual Info Path library was on the parent web. The problem was when i tried to edit the Info Path web part, i could not see the list of Info Path library (from parent web) because it was showing only current site Info Path libraries.

Solution

I added new page in Page/Site Pages library of parent website. I added Info Path web part in the page and copied the Page from parent web to child web. Every thing worked fine in the child web Info Path web part page.

Copy Page to Child Site

Tuesday, September 23, 2014

Copying Web Part Page to same / other list of same web or child web

Problem


There are situations when you want to copy the web part page to same/other list in same web/child web. If you copy the page through SharePoint Designer, it will copy the page but the web parts will be removed.


Solution


Use site Content and Structure.

Procedure

Monday, May 5, 2014

The assembly 'DevExpress ...' is not registered for COM Interop. Please register it with regasm.exe /tlb.

Last week i was stuck in to a problem for registering the DevExpress library. I received following error while compiling the project,

"The assembly 'DevExpress.Utils.v13.2, Version=13.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a' is not registered for COM Interop. 
Please register it with regasm.exe /tlb."

Solution:
1- Open command prompt with administrator privileges and navigate to folder,
C:\Program Files (x86)\DevExpress 13.2\Components\Bin\Framework

2- Run following command,
RegAsm.exe "C:\Program Files (x86)\DevExpress 13.2\Components\Bin\Framework\DevExpress.Utils.v13.2.dll"


Friday, February 21, 2014

Adding Recursive Folders to TFS using C#


Add reference to two dlls

Microsoft.TeamFoundation.Client.dll
Microsoft.TeamFoundation.VersionControl.Client.dll

Include following assemblies,

using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Framework.Client;


Authenticating TFS

// Providing URL, UserName and Password
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri(tfsURL), new                          System.Net.NetworkCredential(userName,password));

// Checking Authentication
tpc.EnsureAuthenticated();

// Getting Version Control instance
VersionControlServer versionControl = tpc.GetService<VersionControlServer>();

Create Simple Accordion with JQuery (Not JQuery UI)

Why not use JQuery UI accordion?

JQuery UI is more professional accordion and has too many options. But in my last project, I had to create accordion having different color coding on each heading background and other rendering options so i just created very very simple accordion.

I have created two Headings and for each heading i have provided class name "question" and for each detail, class name is "answer".When the page is opened first time, you can hide all the details by,   $('.answer').hide();this line can also be written in document.ready method.

Saturday, February 15, 2014

Setting Jquery UI Auto complete on SharePoint Text Filter

Steps,

1- Add Text Filter and List Web Part on the page.
2- Add connection between text filter and List webpart.
3- Open Notepad, Add following script in the Notepad.
4- Change the controlID variable value to the generated client id of Text Filter textbox.
5- Change the List and column names in the SP Service call.
6- Save the file in Site Asset library.
7- Add Content Editor web part on the page and provide link to the text file placed in the Site asset Library.

Enjoy:)