Featured
-
How to enable CORS (Cross-Origin Requests) in ASP.NET Web API
There are certain steps that need to be followed f
by gaurav.gautam -
Why does my CHM have a blank content pane?
Hello Readers, Many times I have heard that, many
by Chetan.Sharda -
How to connect to icloud calendar?
Hello coder's world, To connect to icloud calen
by govind.chauhan -
Working with List in Provider Hosted App for Sharepoint
Sharepoint List in Provider Hosted App This Blo
by shubham.mamgain -
REST attributes of WCF Service
Objective: In this article we will explain what a
by govind.chauhan
Tags
Route Config in Asp.Net MVC
"Basics of Route Config in Asp.Net MVC"
Routing is one of the primary concern of MVC. In MVC we have to map URL to a particular Action method on a particular Controller, the Action Method is then executed and returns a...
Difference between DataTable.Rows.Add(DataRow) and DataTable.ImportRow(DataRow)?
Hello Reader ,
When adding a row to DataTable, there are two methods available in C# and VB.Net i.e.
DataTable.Rows.Add(DataRow) and DataTable.ImportRow(DataRow). Both do the same functionality, adding a row to DataTable but the main differ...
ActionResult in Asp.Net MVC
"ActionResult in Asp.Net MVC"
We all know that ActionResult is a return type mentioned in the Action Method inside a Controller in MVC.
In this article I will explain it in more detail.
Getting s...
Singleton Design Pattern
Singleton Pattern
It restricts object of class to be created only once throught the application and provides global point of access to it. It also comes under creational
pattern like Factory pattern as it allows one of the best way to create ...
How to make JSON.NET as the default JSON serializer in ASP.NET MVC
"Making JSON.NET as the default JSON serializer in ASP.NET MVC"
The default JSON serializer in Asp.Net MVC is JavascriptSerializer.
In this article I will explain how to replace the JavascriptSerializer fo...
Using Null-coalescing operator (??) in C#
We have ?? Operator which is called null- coalescing operator in c#. It takes two operands, one at the left side and one at the right side and checks if the left side operand is null or not. If is is null then it will return the right side operan...
ASP-Net-MVC-The CRUD-Part -1 Insert and Show
Hi Friends,I am back with my MVC article with some new things.
So we've covered the concept and structure of an MVC application in my previous article which are listed below:-
1-ASP-Net-MVC-What-s-inside-Part1
2-ASP-Net-MVC-What-s-inside-Pa...
Difference between is and as keyword in c#
The difference between is and as operator is that:
An object can be cast to a certain type then is returns true otherwise false, but talking about as operator, it is used to cast an object to a specific type but if in any case it is unable to ...
How to export GridView to pdf in asp.net
Hello all,
In asp.net, to show data in tabular form we use GridView Control, in which we can bind our database table directly and at time we need to export the GridView in from of Excel or PDF file format.
To export Grid to PDF, we have fol...
How to export GridView to pdf in .net
Hello all,
In asp.net, to show data in tabular form we use GridView Control, in which we can bind our database table directly and at time we need to export the GridView in from of Excel or PDF file format.
To export Grid to PDF, we have fol...
How to handle an error occurred in finally block
Hello all,
To handle errors in C#, we generally use try, catch and finally methods. but when error occurs in finally block basically three things happens:
.
The exception rises and it needs to
be handled at upper level, but while handl...
Difference between var and dynamic in C#
"Difference between var and dynamic in C#"
To understand the differences more clearly, let us go through the following table:
VAR
DYNAMIC
This was introduced in C# 3.0
This was introduced i...
Factory Pattern
Factory Method Design Pattern
What is Factory Pattern?
Factory pattern is one of the most commonly used design pattern. It comes under creational design pattern as we have control on object creation logic. In this approach we have control o...
How to use chart control in asp.net
Hello all,
Working with asp.net, at times, we have to show graphical reports user which can be implemented using Chart like Area Chart, Bar Chart, Box Plot Chart, Bubble Chart, Column Chart, Doughnut Chart, Line Chart, Pie Chart etc.
In my ...
How to create a DropDownList from an Enum in ASP.NET MVC
"Creating a DropDownList from an Enum in ASP.NET MVC"
In this article I will try to explain, how can we bind an Enum to a DropDownList in ASP.NET MVC.
Let us understand it with the help of an example:
Step 1: Crea...
Implementing Singleton in C#
Hello Friends,
This blog explains how to implement singleton design pattern in c#. So lets start with few basic things:--
What is Singleton ?
A singleton is a class which only allows one instance of itself to be created - and gives s...
How to load xml data into sql server table using SqlBulkCopy
Hello all
Working with SQL Server we have to copy data from multiple sources and from this purpose we can use SqlBulkCopy Class which helps us to bulk copy data from different data sources to SQL Server database. This class is present in the S...
Difference between Html.RenderPartial and Html.Partial
"Difference between Html.RenderPartial and Html.Partial"
Html.RenderPartial and Html.Partial both are the methods to render a Partial View in MVC Razor.
Following table shows the difference between these two:
...
How to export GridView to Excel in .Net
Hello all,
In asp.net we show our database records in tabular format using GridView control and to export that GridView Data to excel, we can use following code packet.
protected void gridViewExportToExcel()
{
if (GridView.Ro...
How to bind DropDownList from DataBase in asp.net
Hello all,
In asp.net we use DropDownList control which has multiple select items(options) from which we can select one.
We can either set the values of DropDownList list items by hard coding it or we can also bind the the select items and se...
How to show JavaScript popup from C#
Hello all,
In asp.net if we want to show JavaScript pop box from Code behind file (C# file), we can do that by using following block of code :
string script = "<script language='javascript'>alert('This is a JavaScript popup');</scr...
Partial view was not found or no view engine supports the searched location
"The partial view was not found or no view engine supports the searched locations."
While working on a Application of rendering Partial View in a parent View, I got the following Exception: "The partial view '~/Home/Par...
How to use Partial View in Asp.Net MVC
"Partial View in Asp.Net MVC"
Key Features:
1. The View defined inside the parent View is called the Partial View.
2. It is same like a user control (.ascx) in Asp.Net.
3. The Partial View has access to the data of the parent View.
4. ...
How to make Custom Error pages in Asp.Net MVC
"Custom Error pages in Asp.Net MVC"
In this article we will learn how to make custom error pages in Asp.Net MVC.
Getting Started:
By default if we get any exception while running our code, w...
ASP.NET MVC Do's and Dont's or Best Practices
Hello Friends, Asp.net MVC is now getting more popular day by day, So before dealing with MVC we need to understand some Do's and Dont's of it. This blog will help you to understand Do's and Dont's of ASP.NET MVC.
ASP.NET MVC Do's and Dont's ...
Deleting a list of objects in Entity Framework
Entity framework provides numerous ways to batch delete the objects from Database. Below are the step for way 1 :
Load objects that has to be deleted in memory.
Remove the objects from context
And then save these changes. This statemen...
How to remove unwanted Namespace in asp.net C#
Hiii All..
Working with asp.net we use using statement to add name space to our code behind file (C# file) if we want to use any specific namespace, but if there are unused using statement that are present in your code than it can cause perfor...
How to View and Download a file in Asp.Net MVC Application
"Returning a file to View/Download in MVC"
In this article I will try to explain how to view and download a file in Asp.Net MVC Application.
Let us understand it with the help of the folowing example.
Getting Starte...
Some Optimization and Performance Tricks in .Net
Hi Friends. My "Hello World" blog in MVC is taking some time ,so I thought that I should share some performance tips here. Some of them are followed by code and explanations and I believe that you'll find them useful.
Static Methods are Faste...
The server response was: 5.5.1 Authentication Required
"Error - The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required."
While I was integrating Email functionality using Gmail SMTP Server in ...
How to Send email with attachment using Gmail SMTP Server in ASP.Net
" Send email with attachment using Gmail SMTP Server in ASP.Net. "
In this article I will discuss how to integrate the email functionality along with the attachment in a Asp.Net Application.
Getting Started:
Step ...
How to generate a dropdownlist control in asp.net mvc using HTML helpers
Hello All,
In MVC (Model, View and Controllers), to create a dropdownlist control we use HTML helpers which helps us to to create various HTML and server side controls.
A dropdownlist is a collection of objects of SelectListItem class in .n...
How to use Razor View Engine in Asp.Net
"Introduction to Razor View Engine"
Razor is used to create dynamic Web pages, it supports both C# as well as VB.Net. Razor is used like a markup syntax for adding server-side code to web pages inorder to make them dyn...
C# Naming Conventions and Coding Standards
"C# Naming Conventions and Coding Standards"
Naming Convention:
Basicaly three types of naming conventions are used in C#, Camel, Pascal and Hungarian.
We should use PascalCasing for class names and method names:
...
What is the difference between var and dynamic keywords in C#
Programming languages can be categorized into two parts based on data type
1) Strongly Type
2) Weakly Type
Strongly Type:-
A strongly-typed programming language is one in which there are dif...
How to call asp net web service from javascript using ajax
Hello all,
To call a web service from JavaScript using ASP.NET AJAX, there are certain steps that you have to follow which are listed bellow :
Decorate web service class with
[System.Web.Script.Services.ScriptService]
Include ScriptM...
WebMethod overloading in asp net web services
Hello all,
Working with .net web services, at time we have to overload our WebMethod, and the process of WebMethod overloading is very much same to the method overloading in C#.
Method overloading allows a class to have multiple methods wit...
How to to convert date string of any format to a desired date format
"Generic function to convert any type date to desired date format"
While working in a project, I got stuck in a issue in which I needed a generic function that converts the date string in any format to a desired date fo...
Exception while parsing String into DateTime
"An exception of type 'System.FormatException' occurred in mscorlib.dll but was not handled in user code while parsing String into DateTime."
I was trying to parse a string "27/06/2015" into the DateTime as follows:
...
What is assembly and strong named assemblies in .net
Assembly is a fundamental unit in .net which is versionable and gets created after successful compilation and it has an extension of .dll or .exe.
Strong naming an assembly is Basically a process of Private and Public Key Pair.
In .Net ther...
How to add marker to a location and resume back to location on Button click in a Google Map
"Add marker to a desired location and resume back to location on Button Click in a Google Map "
In my previous article I explained how to integrate Google Map in a .Net Wb Application, If incase someone has missed it th...
How to Integrate Google Map in a .Net Web Application
"Integrate Google Map in a .Net Web Application"
In this article I have discussed how to integrate Google map in a .Net Application.
Getting Started:
Make a web application, and write the following HTML in the aspx ...
How to Upload File in ASP.NET MVC
"File Upload in ASP.NET MVC"
File upload is one of the common feature that is required in almost every application. In this article we will discuss how to use this upload file functionality in Asp .Net MVC.
Step 1: I...
How to handle multiple submit buttons in Asp.Net MVC
"Handling multiple submit buttons in Asp.Net MVC"
In various cases we have to take multiple submit buttons in a form , I will not discuss the cases but let us take the following example:
<form method="post" action="...
How to bind all dates of month on GridView Header cell in .net
Hello all,
Working with ASP.NET, we wanted to print all the dates of months on the Header cell of GridView based on current month and year dynamically from code behind which can be changes later on by selecting different month and year from th...
MultiView in Asp.NET and how is it different from Panel control
"MultiView in Asp.NET and how is it different from Panel control"
MultiView control is a asp.net web server control, used to create multiple views of a single page.It helps not to create multiple pages for making differ...
How to Deserialize XML using C#
"How to Deserialize XML document in C#"
In this article I have discussed about how to deserialize the XML using C#.
Let us take a simple example to understand better:
<AddressDetails>
<HouseNo>4</...
How to parse JSON in C#
"Parsing Json in C#"
Now a days JSON is the most popularly used data exchange format due to its simplicity and light weight, therefore we will see how to hit the API and then parse the received JSON in C#.
Please go ...
Getting incorrect results while using ToString("dd/mm/yyyy")
"Getting incorrect results while using ToString("dd/mm/yyyy") "
In this article I am sharing one of the issue I got stuck in.
Please go through the following code :
string date = "30,jun,2015";
DateTime dt = C...
How to resize an uploaded image in Asp.net
"How to resize an uploaded image in Asp.net"
In this article I have explained that how to resize the uploaded image and then save it to a location.
Getting Started:
Step 1: Place a FileUpload control, a Button on th...