Welcome to Sudeep Pandey

Just for sharing ideas and knowledge— My Blog

Archive for the ‘.NET’ Category

ASP.NET and JQuery

Posted by Sudeep Pandey on January 18, 2009

JQuery is a library that helps javascript programmer to keep code simple and concise. It simplifies the process of traversal of HTML DOM tree. We can easily handle event, perform animation and add ajax based application using JQuery.

Below are some simple steps to configure JQuery in your ASP.NET Web Project:
Before using JQuery Code in ASP.NET, First we have to download library file from “http://code.google.com/p/jqueryjs/downloads/detail?name=jquery-1.2.6.js”.
Right Click your project in Solution Explorer and add new folder and named it as Scripts.
Right click and click on add existing item and browse to the file where you have downloaded jquery library file, select the file and click add.
Now you can use JQuery library by drag and drop the library file–jquery-1.2.6.js file from the Solution Explorer.

I have demonstrated a simple example of JQuery in ASP.NET. This example explore how to use JQuery to select and unselect all the checkboxes in ASP.NET CheckBoxList.
Copy and paste this code in aspx file:

$(document).ready(function() {
$(‘#chkAll’).click(
function() {
$(“INPUT[type='checkbox']“).attr(‘checked’, $(‘#chkAll’).is(‘:checked’));
});
});

Also copy this code in your cs file:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
cblist.Items.Add(new ListItem(“Items 1″,”Items 1″));
cblist.Items.Add(new ListItem(“Items 2″,”Items 2″));
cblist.Items.Add(new ListItem(“Items 3″,”Items 3″));
cblist.Items.Add(new ListItem(“Items 4″,”Items 4″));
cblist.Items.Add(new ListItem(“Items 5″,”Items 5″));
}
}

Posted in ASP.NET | Leave a Comment »

How to Configure Ajax Control Toolkit

Posted by Sudeep Pandey on December 31, 2008

There are few steps that helps you in configuring ajax control toolkit in Visual Studio 2008::
1)Download AjaxControlToolkit-Framework3.5.zip from http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=AjaxControlToolkit&ReleaseId=8513

2)Create ASP.NET Web Application project.

3)Go into Toolbox, right click and choose Add Tab. Name it as Ajax Control Toolkit. Click on choose items and click on browse button. Then give the location of download file and find a folder SampleWebSite and go inside bin folder, then chose AjaxControlToolkit.dll and click ok.

4) After the third step, you can see the appearance of Ajax Control Toolkit and its components in Toolbox.

5) Now Enjoy the Ajax Control Toolkit.

Posted in ASP.NET | Leave a Comment »

Simple Demonstration of WPF(Windows Presentation Foundation)

Posted by Sudeep Pandey on October 29, 2008

The Windows Presentation Foundation is Microsofts next generation UI framework to create applications with a rich user experience under Windows Vista. It is part of the .NET framework 3.0 and higher.

Advantages of WPF

WPF has a number of advantages over WindowsForms. The following list shows the most important.

* Resolution independence
You specify the size of objects in inches not in pixels. When the screen resolution gets higher, objects just appear crispier but they stay the same size.

* Hardware acceleration
WPFs vector based rendering engine takes advantage of modern graphic cards. This makes the user interface incredibly fast and scaleable.

* Rich composition
WPF controls are highly composable. That means that you can put almost any control into another. This reduces the number custom controls dramatically.

* Templates and Styles
WPFs styling and templating capabilities allows it to entirely replace the look and feel of any controls.

* Documents
WPF has a built in support for complex documents with multi column layouts. It can natively read and write XPS documents.

* Multimedia Support
WPF has a built-in support for audio, video and images. You can play a video with a single line of XAML.

* 3D
With WPF you can create complex 3D scenes including materials with textures, meshes, cameras, lights, etc.

WPF application uses a markup language called as XAML (XML Application Markup Language) and this application can be deployed on the desktop or hosted in a web browser. Microsoft SilverLight is a web based subset of WPF.

Lets demonstrate in a simple program:

The below given is a simple XAMPL file—named it as Window1.xampl. This program creates a GUI which contains a listbox where certain items are listed and one button with text box to add item in a listbox and another button to delete a selected item of listbox.

<Window x:Class=”WPFExmp1.Window1″
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”
Title=”Window1″ Height=”296″ Width=”389″>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width=”278*” />
<ColumnDefinition Width=”0*” />
</Grid.ColumnDefinitions>
<ListBox Height=”100″ HorizontalAlignment=”Left” Margin=”10,10,0,0″ Name=”listBox1″ VerticalAlignment=”Top” Width=”120″ >
<ListBoxItem Content=”Coffee”></ListBoxItem>
<ListBoxItem>Juice</ListBoxItem>
<ListBoxItem Content=”Tea”></ListBoxItem>
<ListBoxItem Content=”Juice”></ListBoxItem>
</ListBox>
<Button Height=”23″ Margin=”138,10,154,0″ Name=”button1″ VerticalAlignment=”Top” Click=”button1_Click”>Add item</Button>
<TextBox Height=”23″ HorizontalAlignment=”Right” Margin=”0,10,36,0″ Name=”textBox1″ VerticalAlignment=”Top” Width=”107″ />
<Button Height=”23″ Margin=”138,40.4,154,0″ Name=”button2″ VerticalAlignment=”Top” Click=”button2_Click”>Delete Item</Button>
</Grid>
</Window>

The code below is code behind code–named it as Window1.xampl.cs.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WPFExmp1
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}

private void button1_Click(object sender, RoutedEventArgs e)
{
listBox1.Items.Add(textBox1.Text);
}

private void button2_Click(object sender, RoutedEventArgs e)
{
listBox1.Items.Remove(listBox1.SelectedItem);
}

}
}

Posted in WPF | 1 Comment »