" Live as if you were to die tomorrow. Learn as if you were to live forever.. "
- Mahatma Gandhi

Code optimization through WeekReference

Posted on November 24th, 2015 by

WeekReference is a new element added into 4.5 framework, but it was available in Java from the earlier stage only. So, this article could be useful for .Net, Java, and Android as well. What is it? It is nothing more than a class but what special about is to interact with Garbage Collector in a certain way […]

Infragistics WebNumericEditor Tip

Posted on November 23rd, 2015 by Palash Mondal

WebNumericEditor is one of the Infragistics Editor controls. Now, WebNumericEditor control will use a comma to separate number groups For example 1234567 will be displayed as 1,234,567 But if you want to prevent 1234567 being displayed as 1,234,567 Here’s the C# code :- //Requires: using System.Globalization; CultureInfo ci = new CultureInfo(“en-US”); NumberFormatInfo nfi = new […]

How to get list of Local and Network Printers

Posted on November 23rd, 2015 by Digvijay Verma

To get the list of printer queue we call the method GetPrintQueues. This method has a number of signatures for populating different kind of printers. PrintServer localPrintServer = new PrintServer();   If you do not pass any argument  (i.e localPrintServer.GetPrintQueues()), it will just return the printer queue attached directly to your machine. But as we […]

Paging in DataList

Posted on November 23rd, 2015 by Tapan Kumar

While using the gridView and listView it is an easier pratice to use the data pager control for pagging purpose. But while you are working with datalist control then you will face the real problem, because the datalist does not support the data pager. In order to impliment the paging functionalty in data list here […]

Difference Between Single ‘&’ Operator And Double ‘&&’ Operator

Posted on November 23rd, 2015 by Anish Thakur

1) Single AND Operator(‘&’) First, It Evaluates All Operands, Then Result Is Declared(Either FALSE Or TRUE). Say For Example: Condition c1-True Condition c2-False i. I Need To Check Condition (c1 & c2) Check First Condition(c1) Then Check Second Operand(c2) And Then Result Is Declared False. ii. I Need To Check (c2 & c1) Check First […]

Exporting Any Data Into Excel File Using Console Application.

Posted on November 23rd, 2015 by Sisir Patro

It is easy to imporrt the data from a gridview to an excel sheet. But when the data comes from a database or any datasource it becomes difficult for us to import them into the excel sheet. I have tried the following code in Console application to export the data from the database. Its not […]

How To Programmatically Get A Selected Text From MS Outlook?

Posted on November 23rd, 2015 by Aniket Banerjee

First of all, you need to add a reference manually to Microsoft.Office.Interop.Outlook.dll. Include the namespace given below: using Outlook = Microsoft.Office.Interop.Outlook; The types and members of the Microsoft.Office.Interop.Outlook namespace provide support for interoperability between the COM object model of Microsoft Outlook 2010 and managed applications that automate Outlook. Now, use the following method to a […]

To break out from a deeply Nested loop

Posted on November 23rd, 2015 by Amit Mohapatra

In this tip I am explaining different ways to break out of a very deeply nested loop. Also the pros and cons of each method. Also show the use of anonymous method for implementing this functionality. Use of anonymous method to break out from a deeply nested loop Sometime we may face a situation when […]

Read and Write Data to Resource File Programmatically

Posted on November 23rd, 2015 by Pallavi Praharaj

Following are the step by step process to create, read and write into resource file using code. 1.Open a new project in c# . 2. Add a ResourceFile.resx in the project. 3. Add a new class and name it as ResourceCreator 4. Add these following namespaces: using System.Windows.Forms; using System.Resources; using System.Drawing; using System.IO; 5.Add […]

Using JSON Extension Methods in WCF Service

Posted on November 23rd, 2015 by Tanveer Singh

Recently i was writing a WCF Service which would be returning me result in JSON Format. I noticed I have to write this code everytime I have to convert the data into JSON strings. How did I avoid repetetive task? By using extension Methods The code I was using before discovering extension methods  is given […]

How to run a console application from web using a buttonClick event

Posted on November 23rd, 2015 by Sisir Patro

I am sharing here the code to call a console application from a web on a button click event. We can track the begin and end time of the application here. The most important thing is we can also check whether the process is already running priorly or not. The code snippet is as follows: […]

Crystal Report viewer object – Why disposing is necessary

Posted on November 23rd, 2015 by Priyojit Mondal

Disposing of object is necessary thing after the job is done, but we hardly take care of this fact. In recent scenario, it hardly mater any space consumption if we don’t dispose any object. But there are some cases where, if you ignore the disposition thing, your life could be hell. One among them is […]

Making Async Request with Framework 4.0 using VS 2010

Posted on November 23rd, 2015 by Tanveer Singh

In C# 4.0 If we want to make any Request to webPages or Services we use the HttpWebRequest/WebRequest in Order to make it which usually sometimes locks up the screen In order to wait us for Response and then traverse the ResponseStream and then READ responseStream.. so In Order to avoid all these we can […]

Use of Path.Combine

Posted on November 23rd, 2015 by Amit Mohapatra

When we want to store the path of a file we are taking the help of a string variable. Generally we store the file path in a string variable and append the file name to this variable to get the full path of a file. While appending generally we use the string concat method. But […]

Determining the path of installer in .NET programmatically.

Posted on November 23rd, 2015 by HARSH WARDHAN

At times you may need to determine the path of the installer while installing your application. For example, you need to run a script or another executable through your installer. Now to find the path of the script(which you need to run through installer), you need to determine the path of your application’s installer. To do […]

Make your windows service desktop interactive

Posted on November 23rd, 2015 by HARSH WARDHAN

Microsoft Windows services enable you to create long-running executable applications that run in their own Windows sessions. Windows services basically do not have any user interface. So you cannot directly pop up any message or launch any form through your windows service. However, if at all there is any need for the UI like notify […]

Creating a SSH connection using ‘plink’ (PuTTY) via C# application

Posted on November 23rd, 2015 by Richi Padhi

What is ‘plink‘? Its a command-line SSH connection method provided by PuTTY. Lets say, you have an application running on windows platform and this application needs to connect to a DB residing on some other platform like Linux, via SSH connection. And you don’t want to manually go and establish the PuTTY connection for each […]

Database Reader Object Parsing in .NET

Posted on November 23rd, 2015 by Vikash Kumar

In many code reviews, I have seen we miss out proper object parsing from SqlReader or end up with repeated lengthy codes or there is no fail safe mechanism to handle, if parse fails out. I will be extending an approach that I have been using in dynamic forms for parsing to make it compatible […]

Parsing XML Content in C# – Possible Errors And Walkthrough

Posted on November 23rd, 2015 by Swaraj Gochhayat

Often we deal with XML content/files in our projects, for read/write/parse/save/delete etc.. operations. The two classes that will come handy in this case are XDocument and XmlDocument. XDocument is what we know as the extended version of XmlDocument which was the standard DOM-Style API for XML whereas the former is the LINQ to XML API. […]

Access Google Drive Content without Authentication(Off Line) in Asp.Net C#

Posted on November 23rd, 2015 by Bhagirathi Panda

To access Google Drive Content we requires two things  1.Refresh Token 2.Access Token(Valid for only one hour) 1.First get the Refresh Token Id to access Google Drive APIOffline. How To Get Refresh Token ID?  -First get Client id and Client Secret by registering you app for api access in Google APIs Console. -Login URL : […]

Compress components in ASP.NET with Gzip

Posted on November 23rd, 2015 by Devi Das

If the response time of your website is high, i.e if it is taking more time to display the content then the user might lose the interest in using the website. So it is important the response should be as fast as possible. Compression is one of the methods in which we can reduce the […]

Capitalizing first letter of each word in a string in C# according to culture.

Posted on November 23rd, 2015 by Shashi Ranjan

Very Often we come across the need to capitalize the first letters of some word or some text. For example : when we want to display users name or city name etc. Recently I came across the same problem . Since string class does not have a method to do this we could think that […]

Closing external windows from your .NET application programmatically

Posted on November 23rd, 2015 by HARSH WARDHAN

Where it can help: Suppose you want to close a window without closing that particular application and you only know the caption of the window. You cannot use process methods as it will close the entire application along with the window. Use the close_window() method along with window caption. Code: Imports System.Runtime.InteropServices <DllImport(“user32.dll”, SetLastError:=True, CharSet:=CharSet.Auto)> […]

HttpHandler(ashx) Vs aspx with Json Data

Posted on November 23rd, 2015 by Shashi Ranjan

Recently I came across a situation where I was using aspx page to return Json Data to bind a flex . It  was going well (mostly all the times ) except a situation (Probality with 1 out of 10 )  where  I was getting redundent  JSON data from aspx page . Then I  got a […]

Creating Downloadable PDF in ASP.NET With Client Side Event Call

Posted on November 23rd, 2015 by Priyojit Mondal

Scenario : There will be a button, when user clicks it, a dialog box will open that provides user with two options, either user can directly view or save the pdf file in his/her local machine. The pdf will contain all the details of a perticuler user whose first and last name will be given […]

How to post on facebook wall

Posted on November 23rd, 2015 by Prachi Mishra

Posting/adding data into facebook Facebook is the most widely used Social Networking site. Thus it will be greatly beneficial for facebook users if they can directly access data outside facebook in their own web sites. This data includes a user’s friend list, live feeds, wall posts and many more. Here I have explained how to […]