Skip to main content

Posts

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           };

Jquery and CheckboxList

In this post i am going to show you how use jquery in asp.net to select the checkbox of Checkbox List <%@ Page Language="C#" AutoEventWireup="true" CodeFile="RadioButtonListJquery.aspx.cs" Inherits="RadioButtonListJquery" %><!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server"><title></title><scriptsrc="Scripts/jquery-1.3.2.js"type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function () { $("#selectAll").click(function () { $("input[type='checkbox'").not("#selectAll").each(function () { $(this).attr("checked", "true"); }); …

How DataContract serialize CLR object into XML

In this post,I am going to show you how DataContract export DataContract into xsd ,and then how an object is converted into xml.





using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.Serialization; using System.Xml.Schema; using System.Xml; namespace DataContract_Demo {     [DataContract(Namespace = "http://aspdotnetcodebook.blogspot.com", Name = "Person")]     publicclass Person     {         [DataMember(Name = "FirstName")]         publicstring FirstName { get; set; }         [DataMember(Name = "LastName")]         publicstring LastName { get; set; }     }     class Program     {         staticvoid Main(string[] args)         {             GenerateXsd();             GenerateXML();         }         privatestaticvoid GenerateXsd()         {             XsdDataContractExporter exporter = new XsdDataContractExporter();             exporter.Export(typeof(Person));             foreach (XmlS…