Skip to main content

Posts

Display parent child data in GridView using usercontrol

In this post I am going to show how to display parent child data in gridview using usercontrol.




Open Visual studio and create a new websiteRight click on App_Code folder ,and add new class named Customer and add following code
using System; using System.Collections.Generic; using System.Linq; using System.Web; publicclass Customer {     public Customer()     {             }     public Customer(int id, string name)     {         this.CustomerID = id;         this.CustomerName = name;         PhoneList = new List<PhoneNumber>();     }     publicint CustomerID { get; set; }     publicstring CustomerName { get; set; }     public List<PhoneNumber> PhoneList { get; set; } } Right click on App_Code folder and add a new class PhoneNumber and add following code into it
using System; using System.Collections.Generic; using System.Linq; using System.Text; publicclass PhoneNumber {     publicint ID { get; set; }     publicstring Number { get; set; }     public PhoneNumber()     {  …

How to download file asynchronously from webserver in asp.net

In this post I am going to show how to download file asynchronously from server using asp.net.
 Open Visual Studio and create a new WebApplication or WebSite Open Default.aspx page and paste following code

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default"     Async="true" %><htmlxmlns="http://www.w3.org/1999/xhtml"><headid="Head1"runat="server"><title></title><scriptsrc="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> </head> <body>     <script type="text/javascript">         function WaitProgress() {             $("#Indicator").text("please wait...");         }         function FinishProgress(contentState) {             $("#Indicator").text(contentState);         }     </script><formid="form1"runat="server&q…

How to use jquery dialog in asp.net

In this post I am going to show you how to use jquery model dialog in asp.net. Note:Please make sure that you have downloaded the jquery and jqueyui   library.



Start visual studioSelect File/New ProjectChoose a Web Site Template -for this example I used Empty Web Site Right click on empty web site and add new class named Person.cs and paste following code



using System; using System.Collections.Generic; using System.Linq; using System.Web; publicclass Person {     publicstring Name { get; set; }     publicstring Email { get; set; }     publicstatic List<Person> GetAll()     {         List<Person> list = new List<Person>()             {                 new Person{Name="John",Email="john@doe.com"},                 new Person{Name="Admin",Email="admin@doe.com"},             };         HttpContext.Current.Session["Add"] = list;         return list;     } }
Right click on empty website and add new item (Ajax Enabled WCF Serv…

How to: Return multiple response from wcf

Imagine you have a wcf application that return xml response but after some time your requirements changed that we want to return multiple response (XML /Json) from the same service.How do you achieved this? Earlier it was nightmare for developer to return multiple response from .net. Now you have a good news that you can return multiple response from wcf 4.0 with a very minimal changes.

So In this post I am going to show you how to return multiple response from wcf in .net framework 4.0

Open visual studio and create an empty website.

Right click on the website project and add a new wcf service.It will create three files named Service.svc,IService and Service.cs. Open IService.cs file and paste the following code


Open Service.cs file and add following code
Right click on App_Code folder and add new class named Person and add following code(This class contains dummy data for demo purpose only ) Till now whaterver I have created so for is normal process for creating wcf service applicatio…

How to:Create wcf application without using config file

In this post i am going to show you how to create wcf application without using config file. Let's start the tutorial.
Open visual studio and create a new console application Right click on the project and add reference to following assemblyusing System.ServiceModel;
Open Program.cs file and paste following code
[ServiceContract]     interface IService     {         [OperationContract]         string HelloWorld(string strMessage);     }     publicclass ServiceImp : IService     {         [OperationBehavior]         publicstring HelloWorld(string strMessage)         {             return ("Hello " + strMessage + "!");         }     }
Now Add following code inside main method

staticvoid Main(string[] args)         {             //Create a URI to serve as the base address             Uri httpUrl = new Uri("http://localhost:8090/MyService");             //Create ServiceHost             ServiceHost host = new ServiceHost(typeof(ServiceImp), httpUrl);����������…

Linq to Sql: Left outer join

In this post i am going to show how to generate left outer join using linq to sql. For this post i am going to use Categories and Product table of northwind. First way to generate left outer join var query=from p in Products join c in Categories on p.CategoryID equals c.CategoryID into pc where p.CategoryID==1 from j in pc.DefaultIfEmpty() select new { CategoryName=j.CategoryName, ProductName=p.ProductName }; ouput generated code SELECT [t1].[CategoryName] AS [CategoryName], [t0].[ProductName] FROM [Products] AS [t0] LEFTOUTERJOIN [Categories] AS [t1] ON [t0].[CategoryID] = ([t1].[CategoryID]) WHERE [t0].[CategoryID] = @p0 second way without using into operator var query=from p in Products from c in Categories.Where(x=>x.CategoryID==p.CategoryID).DefaultIfEmpty() select new { CategoryName=c.CategoryName, ProductName=p.ProductName …

Linq to Sql:Inner join

In this post i am going to show you how to generate inner join using linq to sql.
For this post i am going to use Categories and Product table of northwind.



Let's imagine that you want to fetch CategoryName and ProductName from above table using linq.



var query=from p in Products           join c in Categories           on p.CategoryID equals c.CategoryID           select new           {           CategoryName=c.CategoryName,           ProductName=p.ProductName           };