August 11th, 2009 by Subin
Here’s a small Javascript function which enables animated highlighting effect on the navigation (lavalamp effect) with the help of jquery easing plugin
$.fn.lavalamb = function(ImgPath){
/* ImgPath: Path of the image which you need to animate when you hover over a navigation link
this can be a shadow png image or a pointer image or underline image which you want to animate with a mouseover / mouseout action on a link
Add css class "Highlight" to the node which is currently active, so the image will always be animated back to this node on mouseout
*/
var LeftPos;
$(this).append('<div id="lavalamp"><img src="'+ImgPath+'" alt="" /></div>'); //Appending lavalamb image to the html, this div can be skinned in the css.
$(this).parent().css({position: "relative"}); //setting the position
$("#lavalamp").css({
position: "absolute",top: $(this).height() // These css values can be edited to vertically position the lavalamb image
});
$(this).find("li").hover( //Link hover function
function(){ //Rollover
LeftPos = $(this).offset().left - $(this).parent().offset().left; //calculating the left position
LeftPos = (LeftPos - ($("#lavalamp").width()/2) + ($(this).width()/2)); //calculating the left position
$("#lavalamp").animate({left: LeftPos},{queue:false,duration:700,easing: "easeInQuart"}); //Animating the image from the start position to the current mouseover position
},
function(){
LeftPos = $(this).parent().find("li.Highlight").offset().left - $(this).parent().offset().left; // Getting the position of the highlighted node
$("#lavalamp").animate({left: LeftPos},{queue:false,duration:700,easing: "easeOutQuart"}); //Animating the image back to the start position from the current mouseover position
});
}
And call this function in the html page
<script type="text/javascript">
$("#Navigation").lavalamb("Images/Background/NavShadow.png"); // Navigation is an id of the <UL> list which has navigation nodes
</script>

Here’s an example
Example1
Posted by Subin in Jquery, css, flash, technology | No Comments »
August 6th, 2009 by Subin
Browsers lack good, consistent native audio/video support. (HTML 5’s audio and video are on the way, but not universal yet.)
Here’s Sound Manager 2, a nice Javascript API via Flash + ExternalInterface to add audio & video to your website.
http://www.schillmania.com/projects/soundmanager2/doc/getstarted/#intro
Demo Audios
http://www.schillmania.com/projects/soundmanager2/demo/page-player/
Demo Videos
http://www.schillmania.com/projects/soundmanager2/demo/video/
here is a live example …
http://paris.conciergerie.com/
Posted by Subin in technology | No Comments »
August 4th, 2009 by Zubair Ahmed
Yes Youtube is no more #1 (19th!)
Check out the full listing on PCMag (thanks Hammad)
Posted by Zubair Ahmed in Uncategorized | No Comments »
August 4th, 2009 by Zubair Ahmed
I was facing this problem recently in a project when adding a reference to a WCF Service simply gave me this error.

I google’d it for a while but in vain, I also removed the auto-gen service entries from the web.config but that did not work either.
Then I realized that earlier I had deleted the Service References folder from the application root, re-add and it worked as expected.
Funny thing is that Visual Studio will not tell you what went wrong, neither folder name appears under Add > ASP.NET Folders nor Visual Studio attempts to recreate it.
Tags: Service References, Visual Studio, WCF
Posted by Zubair Ahmed in Uncategorized | No Comments »
August 2nd, 2009 by Subin
It’s always a pain to skin the normal radio/checkboxes and the select lists by using CSS.
I was doing some research on this and figured out a way using javascript/css. I put the functions together in a small jquery plugin.
My idea was to customize the radio/checkbox/listboxes without disturbing the actual markup.
The solution makes use of real radio buttons with labels and their toggle functionality and skinned list-items, allowing radiobutton list rendering and easy skinning.

In the above form thre are a few dropdown lists, radio button and checkboxes. The markup looks like
<fieldset class="Dropdown">
<select class="NonJsSelect">
<option>List Item 1</option>
<option>List Item 2</option>
<option>List Item 3</option>
<option>List Item 4</option>
<option>List Item 5</option>
<option>List Item 6</option>
<option>List Item 7</option>
<option>List Item 8</option>
<option>List Item 9</option>
<option>List Item 10</option>
<option>List Item 11</option>
</select>
</fieldset>
<p><strong>Checkbox controls</strong></p>
<fieldset class="CheckList">
<input type="checkbox" id="CheckBox1" class="Checkbox" />
<label for="CheckBox1">Checklist 1 value </label>
</fieldset>
<fieldset class="CheckList">
<input type="checkbox" id="CheckBox2" class="Checkbox" />
<label for="CheckBox2">Checklist 2 value </label>
</fieldset>
<fieldset class="CheckList">
<input type="checkbox" id="CheckBox3" class="Checkbox" />
<label for="CheckBox3">Checklist 3 value </label>
</fieldset>
Just wrap your controls in a <fieldset> or a <div> and add css classes “Dropdown” for comboboxes and “CheckList” for radio/checkbox controls as shown above.
Download the css/javascript files then add the javascript javascript css references to the page.
Finally just initiate the javascript function
<script type="text/javascript">
$.function(){
$("select").AddSkin();
$(".Checkbox").AddSkin();
//you can reference the controls by its name, id or css class just like any other jquery calls.
}
</script>

You can change the skin by editing the CustomControls.css and replacing the images.
here’s an example
Try it out!
You can download the sample code and plugin from here.
Note: The plugin currently supports only Dropdown, checkbox and radio button controls.
I order to make this work you have to include the latest jquery library.
Posted by Subin in Jquery, css | No Comments »
August 2nd, 2009 by Nauman
Interesting article by Perter Keller, shows how you can get drastic speed improvement by compiling LINQ Queries using System.Data.Linq.CompiledQuery Class in .NET. You can find a complete performance test and sample code, please follow the link http://peterkellner.net/2009/05/06/linq-to-sql-slow-performance-compilequery-critical/
Posted by Nauman in C#, LINQ | Comments Off
July 30th, 2009 by Zubair Ahmed
Hi,
For those with Windows PCs (sorry MAC guys) there’s this nice little tool name Windows Live Writer from Microsoft that can be used for blogging right from the desktop.
Download the tool above and once you install it take a look at the screenshots below that show how I used it to post the last entry.
and BTW, this post is written using WLW
– Add a blog account

- Choose the Blog service

- Put the URL and your credentials

- Hit Next, setup starts

- Just about finished

- Write your post, hit Publish…

..and you’re done..blog away..

Posted by Zubair Ahmed in Uncategorized, work | No Comments »
July 30th, 2009 by Zubair Ahmed
If you have used Elmah for logging exceptions in your Visual Studio projects, you must have used the following syntax in the try..catch blocks
try
{
....
}catch
{
ErrorSignal.FromCurrentContext().Raise(ex);
}
Or if you want to log a custom message you do something like
try
{
...
}
catch
{
ErrorSignal.FromCurrentContext().Raise(new Elmah.ApplicationException(Message));
}
Or also include the exception object with the message like this
try
{
....
}
catch
{
ErrorSignal.FromCurrentContext().Raise(new Elmah.ApplicationException(Message,ex));
}
As you can see this is a lot of text to be put in each try..catch block, so to make it look a little bit nice I made a static class that looks like this
/// <summary>
/// This class logs exception in ELMAH
/// </summary>
public static class Error
{
/// <summary>
/// Logs the exception in ELMAH with a custom message
/// </summary>
/// <param name="Message">Custom message</param>
/// <param name="ex">Exception object</param>
public static void Log(string Message, Exception ex)
{
ErrorSignal.FromCurrentContext().Raise(new Elmah.ApplicationException(Message,ex));
}
/// <summary>
/// Logs the message in ELMAH
/// </summary>
/// <param name="Message">Custom message</param>
public static void Log(string Message)
{
ErrorSignal.FromCurrentContext().Raise(new Elmah.ApplicationException(Message));
}
/// <summary>
/// Logs the exception in ELMAH
/// </summary>
/// <param name="ex"></param>
public static void Log(Exception ex)
{
ErrorSignal.FromCurrentContext().Raise(ex);
}
}
Now the try..catch block looks like this
try
{
.....
}
catch (Exception ex)
{
Error.Log("this is a custom error",ex);
}
Take it away here
Tags: C#, Elmah
Posted by Zubair Ahmed in Uncategorized | No Comments »
July 28th, 2009 by Nauman
Always getting confused to remember difference between Composition and Aggregation, a very good article on C# corner by Phil Curnow, he explained this concept in a simple way, please go through the link
http://www.c-sharpcorner.com/UploadFile/pcurnow/compagg07272007062838AM/compagg.aspx
Tags: C#
Posted by Nauman in C# | No Comments »
July 28th, 2009 by Subin
The Google Map API provides a number of options for manipulating maps and adding content to the map through a variety of services, allowing you to create maps applications on your website.
Here I explored the google map’s Info Window method a bit and demonstrated how to add dynamic content to it.
Suppose in a contact page we have a list company branch information and when clicking each branch, an info window should popup with the corresponding address in a google map placed in the same page.
First of all we need to create an HTML <ul> list with all branch information

The information under each heading either you can make it hidden completely or make it as an accordion.
The html block should look like
<ul id="BranchList">
<li><a rel="25.096803,55.157306" href="#"> Head Office</a> <div class="<span style="color: #ffffff;">Hidden</span>" >
<p><span>Corniche Road, <br/>
Golden Beach Tower, <br/>
Penthouse Level,<br/>
P.O. Box 8206, Abu Dhabi, U.A.E.</span><br/>
Tel: +971 2 409 0700 <br/>
Fax: +971 2 622 1707<br/>
Email: <a href="mailto:info@noreply.com">info@noreply.com</a> </p> </div>
</li>
</ul>
<div id="GoogleMap"></div>
add the latitude and longitude values as a coma separated list as highlighted.
now you need to invoke the javascript function to read the information from the html and place it in the Google Map at the right location.
<script type="text/javascript"><!--
InitiateGoogleMap("GoogleMap","BranchList");
// --></script>

and the javascript function is below
function InitiateGoogleMap(GoogleMapDivId,AddressListElementId){
/*
- To display info window on google map on click of a particular link or button -
GoogleMapDiv : The Id of the div where the map is to be displayed
AddressListElementId : the Id of a UL list where the information displayed.
*/
if (GBrowserIsCompatible()) {
var Map = new GMap2(document.getElementById(GoogleMapDiv)); // Initializing the map
var Coordinates={}; // lat/long values
var Address = $(this).parent().find(".Hidden").html(); // getting the info to be displayed
var point = new GLatLng(parseFloat(Coordinates[0]), parseFloat(Coordinates[1])); //Creating a marker point
var Location = new GMarker(point); initializing a marker
Map.setCenter(new GLatLng(25.096803, 55.157306), 13); // centering the map in a default location
Map.setMapType(G_SATELLITE_MAP); // Setting the Map type
$("#" + AddressListElementId + " li a:first").click(function(){ //Click function
Coordinates = $(this).attr("rel").split(","); lat/long values
Map.addOverlay(Location); //Creating a marker
Map.openInfoWindow(point, $("#"+AddressListElementId +" li:first").find(".Hidden").html()); //Opening the first Item Description in the Map Info Window when the page load
GEvent.addListener(Location, "click",
function() {
Map.openInfoWindow(point, Address);
});
return false;
});
Map.addControl(new GSmallMapControl());
Map.addControl(new GMapTypeControl());
}
}
Note: Jquery plugin and googlemap API references are required to make this work.
You can use Google Map plugins to skin the info window
Tags: C#, google map, html, javascript
Posted by Subin in C#, Uncategorized, flash, identity, iphone, work | No Comments »