Friday, January 20, 2012

jQuery with Visual Studio 2010

JQuery is a free open source JavaScript Library.It simplifies the task of creating highly responsive web pages and works across all modern browsers.


jQuery makes it simple getting and manipulating page contents and has a sophisticated effects library like animation without using additional plugins.

JQuery leverages your existing knowledge of CSS. JQuery makes it easy working with sets of elements like say paragraphs in a page of list items in an ordered list.

It is possible to perform multiple operations on a set of elements with onle line of code known as statement chaining.

Visual Studio 2010 has default support for jQuery.


If you start a New Web Site in Visual Studio 2010 you can see that a Script folder is present.

Inside that you can see 3 jquery files. jquery-1.4.1.js is the developer version which is of 165 kb size. jquery-1.4.1.min.js is the minified or production version which is of  71 kb and jquery-1.4.1-vsdoc.js which is the version with extra comments that enable visual studio intellisense for jQuery.

I strongly recommend you exploring these three jquery files.

Add a script referencet to  the  jquery library and let's explore the first example.
$("document").ready(function Hello() {
            alert("Welcome to JQeury");
        });
   

The $() function (an alias for the jQuery() function) returns a special JavaScript object containing an
array of the DOM elements that match the selector.
document.ready() function gets triggered after the whole DOM tree of the page gets loaded.

 jQuery Selectors and filters
jQuery selectors and filters retrieve contents from the document so it can be manipulated using other functions. This is the query part of jQuery.

JQuery selectors return an array of objects that match the selection criteria. JQuery filters operate on a selector to further refine the results array that the selector returns.

Thing to be noted is  that the array that selector returns is not a set of DOM elements. It is a collection of jQuery objects that provide a large number of predefined functions for further operating on the objects.


 


Selector

Intend

tagname

Find all elements that are named tagname

#identifier

Finds all elements with ID of identifier

.className

Finds all elements that have class attibute with the value of className

tag.className

Gets elements of  type tag that have a class attribute with the value of
className

tat#id.className

Retrive the tag element that has a ID of id and a class attribute with the value
of className


You can observe that jQuery have borrowed heavily from CSS making it easy for a person with knowledge in CSS to the transformed to jQuery.

For example, if you want to hide all the paragrahs in a page. The jQuey command will be :

$("p").hide()



<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script>
        $("document").ready(function () {
            $("p").hide()
        });
    </script>
    <title>Shalvin jQuery</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    </div>
    </form>
    <p>
        Shalvin Specializations</p>
    <p>
        Asp .net</p>
    <p Id = "Orm" >
        Entity Framework</p>
    <p>
        C#</p>
    <p>
        VB .Net</p>
    <p>
        SQL</p>
</body>
</html>


Suppose you want to hide only the paragrph with the id Orm the jQuery command will be as follows:
$("#Orm").hide()

To be continued..

Thursday, November 10, 2011

Barcamp Kerala 11

Barcamp Kerala 11

Venue : IIM Calicut
Date : 20th November 2011

Sessions
Microsoft Silverlight                                            -  Shalvin P D
IITs & IIMs - Are they (still) Socially Relevant ?  - Praseed Pai
Making your First Dollar with your PC                 - Arun Basil Lal
Html 5 and Beyond                                             -  Shwetank Dixit
Social media and Business                                   - Hari K T
The Conversation Club                                        - Sebastian Panakal

Session details

 

Wednesday, August 17, 2011

Kerala Microsoft User Group - August 1011 Meeting

20th Aug 2011 - Kochi



Venue: Orion India Systems Pvt Ltd, 103, 2nd floor, Tejomaya, Info park SEZ, Kakkanad, Kochin-682030


Agenda

09:30 - 09:40 Community updates

09:40 - 11:00 "Design Patterns in .Net" by Yanesh Tyagi

11:00 - 11:45 JavaScript MVVM in ASP.NET with KnockoutJS by Shiju Varghese

11:45 - 12:00 Tea Break (15 min)

12:00 - 12:45 Instrumenting & Profiling in .NET Apps" by Abraham Peter

12.45 - 01:00 Ask the experts





Mono

Mono is open source cross platform implementation of .Net I am using Mono in Ubuntu 10.10.
The preferred way to develop Mono in Linux is using MonoDevelop. MonoDevelop is a Mono IDE.

First let's see how to develop Console Application in Mono.
Once you have installed Mono you can go to the Terminal by going to Application, Accessories and select Teminal. The mono C# compiler is mcs.

class Hello
{
  public static void Main()
  {
    System.Console.WriteLine("Shalvin");
  }
}



So type mcs .cs in the terminal for compiling the C# file.
Once it is compiler you can access the exe using
mono .exe.


















Windows Forms
using System;
using System.Windows.Forms; 

class frmHello : Form
{
  public static void Main()
  {
    Application.Run(new frmHello());
  }
}

Monday, July 18, 2011

Ado .Net DataSet and WPF

If an element uses a binding expression and its DataContext property is null the element continues its search up the element tree. This search continues until the element finds a data object or reaches the toplevel container, which is the user control that represents the page.


using System.Data;
using System.Data.SqlClient;


SqlConnection cnn;
SqlDataAdapter da;
DataSet ds = new DataSet();
private void Window_Loaded(object sender, RoutedEventArgs e)
{
    cnn = new SqlConnection(@"Data Source=.\sqlexpress;Integrated Security=sspi;Initial catalog=AirLines");
    cnn.Open();
    da = new SqlDataAdapter("select * from Location", cnn);
    da.Fill(ds, "Loc");
    LayoutRoot.DataContext = ds.Tables["Loc"];
}


<Grid Name="LayoutRoot">
<ListBox ItemsSource="{Binding}"
            DisplayMemberPath="LocationName"
            Height="100" HorizontalAlignment="Left" Margin="10,10,0,0" Name="listBox1" VerticalAlignment="Top" Width="120" />
</Grid>


Binding to DataGrid

<Grid   Name="LayoutRoot">
    <DataGrid ItemsSource="{Binding}" AutoGenerateColumns="True" Height="150" HorizontalAlignment="Left" Margin="17,13,0,0" Name="dataGrid1" VerticalAlignment="Top" Width="325" />
</Grid>


WPF DataGrid Custom Columns
<Grid   Name="LayoutRoot">
<DataGrid ItemsSource="{Binding}" AutoGenerateColumns="False"  HorizontalAlignment="Left" Margin="42,12,0,0" Name="dataGrid1" Width="296">
    <DataGrid.Columns>
        <DataGridTextColumn Header="Serial No" Binding="{Binding LocationId}" />
        <DataGridTextColumn Header="Location Name" Binding="{Binding LocationName}" />
        <DataGridTextColumn Header="Latitude" Binding="{Binding Latitude}" />
        <DataGridTextColumn Header="Longitude" Binding="{Binding Longitude}" />
    </DataGrid.Columns>
</DataGrid>
</Grid>

{Binding LocationName} is the shorthand to {Binding Path=LocationName}


Thursday, July 7, 2011

User Group Meeting - 9th July 2011 - Kochi

Venu: Orion India Systems Pvt Ltd, 103, 2nd floor, Tejomaya, Info park SEZ, Kakkanad, Kochin-682030




09:30 - 09:40 Community updates
09:40 - 10:40 C# Test Automation by Praseed

10:40 - 11:20 Silverlight - Prism by Mahima
11:20 - 11:40 Tea Break (15 min)
11:40 - 12:30 Sharepoint 2010 programing by Abraham
12.30 - 01:00 Ask the experts


Register

Wednesday, June 8, 2011

User Group Meeting - 11th June 2011 - Kochi

Venu: Orion India Systems Pvt Ltd, 103, 2nd floor, Tejomaya, Info park SEZ, Kakkanad, Kochin-682030

Agenda

09:30 - 09:40 Community updates
09:40 - 10:30 Scaffolding with EF 4.1 and ASP.NET MVC 3
10:30 - 11:15 Debugging Techniques in Visual Studio
11:15 - 11:30 Tea Break (15 min)
11:30 - 12:30 Introducing Parallel programming in .net 4.0
12.30 - 01:00 Ask the experts

Register

Details

It is a free event. Please convey the message to your friend and ensure their participation.

Tuesday, May 10, 2011

Converting Silverlight Application to use WCF RIA Services

Enabling WCF RIA services to an existing Silverlight application is easy and straight forward. Navigate to the properties of Silverlight Project and go WCF RIA Services Link and select the ProjectName.Web.