Sunday, 13 November 2011

Unable to make the Session State request to session state server.


When you get this error just type services.msc in the run and the start the Asp.net  State services and then run your application

Tuesday, 18 October 2011

Adding a new Item to a DropDown using Jquery.

Use any one of the Technique to add an item to a 
drop-down control:


$('#Coupon_Cities').append("<option value="-1">"All Cities"</option>");

OR

$('#Coupon_Cities').append($("<option></option>").val("-1").html("All Cities"));

OR 


$('#Coupon_Cities').append(new Option("All Cities", -1));
 
OR  
 
$("<option value=’-1’>All Cities </option>")
                                   .appendTo("#Coupon_Cities"); 




Friday, 14 October 2011

How to display the first letter a big in html / Use of CSS :first-letter Selector

<html>
<head>
<style type="text/css">
p:first-letter
{
font-size:300%;
color:#8A2BE2;
}
</style>
</head>
<body>

<h1>Welcome to Html-CSS World</h1>
<p>My name is Sudarsan.</p>
<p>I stay at Hyderabad.</p>
<p>I am a developer.</p>

</body>
</html>

output:

Welcome to Html-CSS World

My name is Sudarsan.
I stay at Hyderabad.
I am a developer.


Tuesday, 4 October 2011

Writing a LINQ query with Join and Where Condition.

var products = from p in context.Products
               join c in context.Categories on p.CategoryID equals c.ID  
               join b in context.Brands on p.BrandID equals b.ID
               where c.ID==-1 || categoryIDs.Contains(c.ID.ToString()) 
               && b.ID==-1 || brandIDs.Contains(b.ID.ToString())
&& coupon.Cities=="-1" || cityIDs.Contains(cityID.ToString())
               select p.ID.ToString();
 
Here context is the EntityModelDataContext.categories(Category),brands(Brand),
products(Product) are the tables in the DB.
 
Note:You can select combination of field from different tables and create a new one as: 
 
var products = from p in context.Products
               join c in context.Categories on p.CategoryID equals c.ID  
               join b in context.Brands on p.BrandID equals b.ID
               where c.ID==-1 || categoryIDs.Contains(c.ID.ToString())
               && b.ID==-1 || brandIDs.Contains(b.ID.ToString()) 
               && coupon.Cities=="-1" || cityIDs.Contains(cityID.ToString())
               select new { p.ID.ToString(),b.BrandName,p.ProductName;}
or
Even you can create a new constructor  as select new XYZ() { fields1...,field2....} 
where XYZ is a new Model