ASP.NET 4.0 Web Control ClientID


In ASP.NET, each web control is identified uniquely using the ‘ID’ property of the control. We can access the server controls in the code behind using this ‘ID’ property. However, when the web form with server side controls renders in the form of HTML, the server side ID gets converted into client side ID. 

Tracing in .Net 2.0

Tracing is a new feature given in .Net 2.0 that helps the user to view different steps occurred while execution of a single Page at run time. Tracing Information help you to investigate errors or unwanted results while ASP.Net process a page request.

CSS: Change Image of Button On Hover and Disabled

This article helps to understand how CSS is changed automatically when a button is disabled from the server side. Further, how to define CSS when a user hovers over an element.

Tweeter search application with Silverlight (Beginners) your first Silverlight application

Developers who are new to Silverlight or in learning phase this demo/article can help them creating a small application. This isn't just a hello world application this something interesting more than that. So ready to get your hand dirty with some XAML code and little bit power of Silverlight.

Editing the Path of any Shape in XAML Silverlight

In Expressing Blend we are not only limited to draw some primitives line rectangle, line or ellipse. Expression Blend help us to create any shape. Expression Blen has two tools named Pen and Pencil which let us to create path and selection cursor let us to modify the shape. Let's create any shape using these tools.

Add a polygon to the Silverlight Bing Map

MapPolygon:The MapPolygon class accepts a list of points that define its shape and location on the map.

MapPolygon class is used to represent a polygon on the map.

Getting started with testing an ASP.NET Webforms Application (MVP Pattern)

In this article we explore how unit tests are created in an ASP.NET WebForms Application. Although there are sections that are specific to the MVP pattern, there are also a few tips and guidelines about Unit Testing of a Web Application in general.

CUDA integration with C#

CUDA enabled hardware and .NET 4 (Visual Studio 2010 IDE or C# Express 2010) is needed to successfully run the example code. Visual C++ Express 2008 has been used as a CUDA C editor (2010 version has changed custom build rules feature and cannot work with that provided by CUDA SDK for easy VS integration).

Playing and Controlling Video Playback in XAML Silverlight

Using videos in a Silverlight based application is a very exciting feature that come early Silverlight 2. Today we see the most extended Silverlight specially Microsoft added GPU Hardware Acceleration for video and bitmap in Silverlight 3 and now Silverlight 4 supports the output protection for video and audio.

Silverlight Bing Map Control in SharePoint 2010

Silverlight Bing Map Control in SharePoint 2010

In this article we will be seeing how to use Silverlight Bing map control in SharePoint 2010.

Security model of Internet Information Services for ASP.NET

IIS has its own security configuration and even for any request reaching the ASP.NET runtime, IIS verifies the request with it's own security configuration. So the first gatekeeper in the ASP.NET security pipeline is actually IIS. So let us understand those security mechanisms which IIS implements:

Database Binding with Accordion Control

This article demonstrates how to bind an Accordion Control with a database in ASP.Net using Ajax.

We are assuming that you have already completed the installation of the Ajax Toolkit as well as have a basic understanding of coding.

Hosting Mobile WebSite Under IIS

First we have to create a mobile web application. For how to create a mobile web site see my previous article Developing Mobile Pages.

What is Foreground or Background Thread

Threading is a concept we all understand and most of us would have implemented them in real world applications. Here is one more explanation of inner level detail on threads - that is Foreground and Background threads.

Pop Search Form Control in Silverlight

Silverlight is a new and powerful browser plug-in that works with Mac OS, Windows and Linux. It helps you create rich web application that is safe, secure and scalable cross-platform. This article will use Visual Studio 2008 to create Silverlight pop search form control.
System Requirement

Use of Stopwatch Class in C#


Using the following line a new stopwatch object will be created:
System.Diagnostics.Stopwatch myStopWatch = newSystem.Diagnostics.Stopwatch();
The "Start" method will start the stopwatch:

Resource Management In Silverligt 3

The files required for any Application to run other than project related files are called resources. It can be a text file or image file or any other file. In this article, we will be seeing how images can be accessed in various ways in a Silverlight application.

Splash Screen in Silverlight 3 Application

If a Silverlight application is small, it will be downloaded quickly and appear in the browser. If a Silverlight application is large, it may take a few seconds to download. As long as your application takes longer than 500 milliseconds to download, Silverlight will show an animated splash screen.

InitParams in Silverlight

If you are developing a Silverlight Application, and you need to pass some parameters inside รข€“ for example a key and value pair then we can pass the key value pair from the aspx page itself. We will see how we can do this in Silverlight.

Scene Order (Layer Order) in XAML Silverlight

XAML is fully based on composition of object scenes. Every XAML page has a parent/top most container (like UserControl/Canvas/Page etc) and it may have zero or more children elements (like Grid/Rectange/Ellipse etc). Look at the example below:

Plane Projection in Silverlight 3

In this article we will see Projection in Silverlight, which describe how to transform an object in 3-D space using perspective transforms. In this article we will use Plane Projection, which represents a perspective transform (a 3-D-like effect) on an object.

File Uplalod from Silver Light application to server location using WCF

This article will explain, How to upload a file from SilverLight client to server location using WCF.
To achieve above task, follow the below steps. Assume, that Reader has a basic concept of

Hello Program in Silverlight using Expression Blend & Visual Studio

Install Expression Studio (it includes Blend, Encoder, Design, Web applications) for Visual Studio so that we can start developing Silverlight by using either Visual Studio or Expression Blend. Finally, what we have here is, Expression Blend adds the features to existing Visual Studio.Creating "Hello" Program using Expression Blend

Let's start Expression Blend; you will get the following splash screen at first.


This screen loads all necessarily program files to memory for building Silverlight Application. After a couple of seconds, you will get the following screen.


In this screenshot, look at the items in the red circle.


This tab lets us open any recently used projects from a list, create a new project or open any existing projects.


This tab lets us open the User Guide by visiting online tutorials or web communities.


This tab provides sample projects developed by Expression Blend development team from Microsoft or somebody else.

Now, let's click on the "New Project" option; you will get the following screen.


As marked in screenshot.

Project Types

In the above screenshot, look at the red rectangle. There are two project type options available; Silverlight and WPF. Here are some major differences between them.

Silverlight and WPF (Windows Presentation Foundation) are two different products from Microsoft, but they have lots of overlap. WPF is a Microsoft technology meant for developing enhanced graphics applications for desktop platform. In addition, WPF applications can be hosted on web browsers which offer rich graphics features for web applications, but it is limited to Operating Systems. Web Browser Applications (WBA), developed on WPF technology uses XAML (read as Zameel) to host user interface for browser applications. XAML stands for eXtended Application Markup Language which is a new declarative programming model from Microsoft. XAML files are hosted as discrete files in the Web server, but are downloaded to the browsers and converted to user interface by the .NET runtime in the client browsers. WPF runs on .NET runtime and developers can take advantage of the rich .NET Framework and WPF libraries to build really cool windows applications. WPF supports 3-D graphics, complex animations, hardware acceleration etc.

Creating nice tab feature in Silverlight

This article uses cool animation in silverlight to create a tab bar like look. Create two custom button controls in the sample for the two tabs you see in the picture above. 

SelectedValue and SelectedValuePath in Silverlight 4

In this article we will see about SelectedValue and SelectedValuePath while Binding. This feature is added in Silverlight 4.

Busy Indicator Control In Silverlight 3

Busy Indicator is a control that is added in Silverlight 3 Toolkit November 2009 Release. In this article we will see how to use it.

Tweak Theme in Silverlight 3

In this article we will see how we can reduce Silverlight application's xap size. As you know themes are provided by Silverlight Toolkit. But if you include multiple themes your application would be too big.C:\Program Files\Microsoft SDKs\Silverlight\v3.0\Toolkit\Jul09\Themes
Now suppose you need a theme style from Shiny Red a Shiny Blue for two different Buttons.

Open the related xaml in Visual Studio IDE.

Search for Button and you will be navigated to Button Style.

Copy the Button Style to your App.xaml.

Don't forget to copy the namespaces too.

Give a x:Key value to the Style in our case BlueStyle and RedStyle.

Copy the StaticResource constants and change the key appropriately. (You have change it carefully where you are using it.)

Here is the Xaml for the blue theme style buttons.

Application.Resources>        <!--Shiny Blue Color Constants-->        <Color x:Key="NormalBrushGradientBlue1">#FFBAE4FF</Color>        <Color x:Key="NormalBrushGradientBlue2">#FF398FDF</Color>        <Color x:Key="NormalBrushGradientBlue3">#FF006DD4</Color>        <Color x:Key="NormalBrushGradientBlue4">#FF0A3E69</Color>

Control focus and Default button in

Setting focus to a control is simple known one for most of us. A focus means the control is going to receive the input from the user. If you type something, the typed stuff goes into the control which currently on focus.

What are sealed classes and sealed methods


Sealed Class

Sealed class is used to define the inheritance level of a class.
The sealed modifier is used to prevent derivation from a class. An error occurs if a sealed class is specified as the base class of another class.

Generating Random Passwords with ASP. NET and C#

Generating random passwords can increase the security of a website by taking the process out of the hands of the user, or simply providing an alternative, and thus reducing the chance of easily-guessable passwords being used. This tutorial shows a simple method of creating a random password.

Webcam Capture and save clip in Silverlight 4.0 with outofBrowser (o.o.b) Application

In this article, how to capture a frame from a Web Camera using a Silverlight 4.0 Application is described.

Converting Numbers to Words in C#

The program supports both the US and UK numbering systems. For example the number 620 would be expressed as follows:

    Six Hundred Twenty   (in the US system)
    Six Hundred and Twenty  (in the UK system)

Use JSON and JavaScript to create a lightweight GridView

This post is going to show you how to use JSON and JavaScript to create a light weight GridView in JavaScript.
1. converting data in JSON
2. using JavaScript to create GridView
3. applying paging and sorting to it.

Creating Credential Store for Form Authentication in ASP.NET 3.5

When we don't want to use Windows Credentials to validate a user, we can utilize the ASP.NET infrastructure to implement our own authentication infrastructure which includes a custom login page that validates a user against credentials such as a database and later established security context on each request. ASP.NET leverages it's framework to support cookies and establishes the security context for each web request; this is called form authentication.

Implementing the QT Algorithm using C#

Quality Threshold (or QT) is an algorithm used in cluster analysis which is described in this Wikipedia article (

The basic idea of cluster analysis is to partition a set of points into clusters which have some relationship to each other. In the case of QT the user chooses the maximum diameter (i.e. distance between points) that a cluster can have and each point is then considered in turn, along with its neighbors, and allocated to a cluster.

The source code is listed below in case it is of interest to anyone else involved in this specialized field.

Source code including sample data

System;using System.Collections.Generic;
struct Point{
    public int X, Y;
    public Point(int x, int y)
        this.X = x;
        this.Y = y;
    public override string ToString()
        return String.Format("({0}, {1})", X, Y);

    public static int DistanceSquared(Point p1, Point p2)
        int diffX = p2.X - p1.X;
        int diffY = p2.Y - p1.Y;
        return diffX * diffX + diffY * diffY;
static class QT{
    static void Main()
        List<Point> points = new List<Point>();
        // sample data        points.Add(new Point(0,100));
        points.Add(new Point(0,200));
        points.Add(new Point(0,275));
        points.Add(new Point(100, 150));
        points.Add(new Point(200,100));
        points.Add(new Point(250,200));
        double maxDiameter = 150.0;
        List<List<Point>> clusters = GetClusters(points, maxDiameter);
         // print points to console        Console.WriteLine("The {0} points are :\n", points.Count);
        foreach(Point p in points) Console.Write(" {0} ", p);
        // print clusters to console         for(int i = 0; i < clusters.Count; i++)
           int count = clusters[i].Count;
           string plural = (count != 1) ? "s" : "";
           Console.WriteLine("\nCluster {0} consists of the following {1} point{2} :\n", i + 1, count, plural);
           foreach(Point p in clusters[i]) Console.Write(" {0} ", p);
    static List<List<Point>> GetClusters(List<Point> points, double maxDiameter)
        if (points == null) return null;
        points = new List<Point>(points); // leave original List unaltered         List<List<Point>> clusters = new List<List<Point>>();
        while (points.Count > 0)
            List<Point> bestCandidate = GetBestCandidate(points, maxDiameter);

        return clusters;
    /*         GetBestCandidate() returns first candidate cluster encountered if there is more than one
        with the maximum number of points.
    static List<Point> GetBestCandidate(List<Point> points, double maxDiameter)
        double maxDiameterSquared = maxDiameter * maxDiameter; // square maximum diameter                List<List<Point>> candidates = new List<List<Point>>(); // stores all candidate clusters        List<Point> currentCandidate = null; // stores current candidate cluster        int[] candidateNumbers = new int[points.Count]; // keeps track of candidate numbers to which points have been allocated        int totalPointsAllocated = 0; // total number of points already allocated to candidates        int currentCandidateNumber = 0; // current candidate number
        for(int i = 0; i < points.Count; i++)
            if (totalPointsAllocated == points.Count) break; // no need to continue further             if (candidateNumbers[i] > 0) continue; // point already allocated to a candidate            currentCandidateNumber++;
            currentCandidate = new List<Point>(); // create a new candidate cluster            currentCandidate.Add(points[i]); // add the current point to it            candidateNumbers[i] = currentCandidateNumber;
            Point latestPoint = points[i]; // latest point added to current cluster            int[] diametersSquared = new int[points.Count]; // diameters squared of each point when added to current cluster
            // iterate through any remaining points            // successively selecting the point closest to the group until the threshold is exceeded            while (true)
                if (totalPointsAllocated == points.Count) break; // no need to continue further                                int closest = -1; // index of closest point to current candidate cluster                int minDiameterSquared = Int32.MaxValue; // minimum diameter squared, initialized to impossible value 
                for (int j = i + 1; j < points.Count; j++)
                   if(candidateNumbers[j] > 0) continue; // point already allocated to a candidate           
                   // update diameters squared to allow for latest point added to current cluster                    int distSquared  = Point.DistanceSquared(latestPoint, points[j]);
                   if (distSquared > diametersSquared[j]) diametersSquared[j] = distSquared;
                   // check if closer than previous closest point                   if (diametersSquared[j] < minDiameterSquared)
                       minDiameterSquared = diametersSquared[j];
                       closest = j;

                // if closest point is within maxDiameter, add it to the current candidate and mark it accordingly                if ((double)minDiameterSquared <= maxDiameterSquared)
                   candidateNumbers[closest] = currentCandidateNumber;
                else // otherwise finished with current candidate                {
            // add current candidate to candidates list            candidates.Add(currentCandidate);
        // now find the candidate cluster with the largest number of points        int maxPoints = -1; // impossibly small value        int bestCandidateNumber = 0; // ditto        for(int i = 0; i < candidates.Count; i++)
           if (candidates[i].Count > maxPoints)
               maxPoints = candidates[i].Count;
               bestCandidateNumber = i + 1; // counting from 1 rather than 0           }
        // iterating backwards to avoid indexing problems, remove points in best candidate from points list        // this will automatically be persisted to caller as List<Point> is a reference type        for(int i = candidateNumbers.Length - 1; i >= 0; i--)
            if (candidateNumbers[i] == bestCandidateNumber) points.RemoveAt(i);

        // return best candidate to caller                        return candidates[bestCandidateNumber - 1];


File Transfer Program using C#.Net Windows Application

How to easily send files (including Audio, Video, doc or any type of file) from Client to Server. System.Net.Sockets;using System.IO;

Then write code for the button1 (Browse) and the button2 (Send) as in the following.

For example:

using System;

Select Single Radio Button in Gridview in Asp.Net

In this article we will learn how to select only one row of a GridView using RadioButtons whereas normally a RadioButton does not support selection of only one RadioButton within a row.


In ASP.Net the GridView control does not support selection of a single RadioButton that works as a group across rows. Generally as you know a RadioButton is a control that works in a group for selecting only one option. If we take RadioButtonList control it will work everywhere, which applies to a GridView also but if we use only one RadioButton control for each row in GridView it will not allow us to select only one. Try selecting a RadioButton in every row; it will allow selection of multiple rows in GridView. Here we will see how to restrict the user to select only one RadioButton within a GridView control.

For doing this task need to write some Javascript function. We will step by step follow.

Step 1:

Start new website. Put the GridView control on the Default.aspx page with RadioButton control in TemplateField like bellow.

ID="GridView1" runat="server" AutoGenerateColumns="False"
            DataKeyNames="AuthId">            <Columns>            <asp:TemplateField ShowHeader="false">            <ItemTemplate>            <asp:RadioButton ID="rdbauthid" runat="server" onclick="javascript:CheckOtherIsCheckedByGVID(this);" />            </ItemTemplate>            </asp:TemplateField>            <asp:BoundField HeaderText="AUTHOR NAME" DataField="AuthName" />            <asp:BoundField HeaderText="AUTHOR LOCATION" DataField="AuthLocation" />            </Columns>

In the above you may see that in the Click event of the RadioButton control I call a Javascript function.

Step 2:

Write the script as below for checking the current selection of the RadioButton control; if more than one is selected then the other selection is removed. Other than this there are two more methods to do same task.
<script type="text/javascript">            function CheckOtherIsCheckedByGVID(spanChk) {
                var IsChecked = spanChk.checked;
                if (IsChecked) {
           = '#228b22';
           = 'white';
                var CurrentRdbID =;
                var Chk = spanChk;
                Parent = document.getElementById("<%=GridView1.ClientID%>");
                var items = Parent.getElementsByTagName('input');
                for (i = 0; i < items.length; i++) {
                    if (items[i].id != CurrentRdbID && items[i].type == "radio") {
                        if (items[i].checked) {
                            items[i].checked = false;
                            items[i] = 'white'
                            items[i] = 'black';


Verify Email Online

We had a database of hundreds of emails which were collected over years. The problem here is that some of the email exists, some do not. So while sending notifications to clients, the retuned invalid user mail messages require a lot of manual work to clear them. Our idea is to verify whether an email exists before sending the mail. Everything should be automatic and less time consuming.

E-card generator using ASP.NET 3.5

Let us generate a simple e-card generator using ASP.NET 3.5. In this we are dividing the web page region into two half on the left there is an ordinary <div> tag containing a set of web controls for specifying card option and on right is a panel control which contains two other controls like iblgreeting and imgDefault that are used to display user configurable text and a picture.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GreetingCardMaker.aspx.cs"    Inherits="GreetingCardMaker" %>

<html xmlns="">
<head id="Head1" runat="server">
    <title>Greeting Card Maker</title>
    <form id="Form1" runat="server">
            <!-- Here are the controls: -->
            Choose a background color:<br />

Screen Layout Designing in a Movie Theater using GridView

In this article, GridView control as a movie screen layout like shown in below images in ASP.Net is explained

Add a Favicon to your ASP.Net page

A favicon is the little image displayed at the left edge of the address bar in most browsers, or on the tab. Adding a Favicon is a nice way to enhance your website and give it a finished look. 

Looking inside Global.asax application file in ASP.NET 3.5

What is Global.asax file: global.asax allows us to write event handlers that react to global events in web applications.

PrintPreviewControl in C#


The PrintPreviewDialog control displays the Print Preview Dialog with all buttons and settings so the users can change their settings before a document goes to the printer. But there are circumstances when you would need to just display print preview without any buttons and options and show only the preview. This is where the PrintPreviewControl can be used. 

Looking deep inside PostBack and ViewState in ASP.NET 3.5


ASP.NET helps in rapid development of web forms in a way similar to our Windows counterpart writes code to develop Windows application for the desktop. Development is rapid in a Windows application for many reasons, i.e. there is no page life cycle etc.

Send an Email with attachment from Outlook, Yahoo, Hotmail, AOL and Gmail


Already loads of information are available on internet for the same purpose. But not all the code is placed at one place. So here is my small effort to accumulate all the code at one place and that is nothing better than this place. Hopefully it will be helpful for the beginners or whoever in needs of it. 

Searching in user profile properties


Using ASP.Net 2005 login controls saves time and effort and produces a professional user management on your ASP.NET web site. User Profile is responsible for extending user properties; but there was a problem faced me that searching is not supported in user profile properties.

Search in Asp.Net


In this article we will see how to implement a search facility in our ASP.Net web site.We can implement such a search facility in our ASP.Net web site for searching for a particular word on a page. For this use a third party control that provides a search box and a search result to control this operation.

BulletedList Control in ASP.NET Framework 4, 3.5, 3.0, 2.0


BulletedList Control will generate or be rendered into a list of items in a bulleted format, even we can attach an image as bulleted style format. BulletedList Control is inherited from ListControl. Here are the list of different Bulleted Styles:

Multi Language Web-Site in ASP.NET


Here we will learn how to translate ASP.Net pages in a user selected language. This article explains step-by-step how to implement your website in multiple languages.

Paging for First, Next, Previous and Last in gridview


This Article explains how to do Paging for First, Next, Previous and Last in A GridView.

Insert HINDI Font from ASP.NET web page to SQL Server database

We are In many sites to save HINDI data in SQL data base. But is too difficult to insert HINDI font in data base.

Get Child window values to parent using javascript

Through this article we will try to popup a child window and from there we will try to return a row data and populate into parent page using javascript. 

How to go back to the same position in a given view inside a multiview


Multiviews are commonly used in pages, but one flaw is observed by users which is the following:Suppose you have web page using Multiview and which is too long that you have to use the vertical scroll bar to focus on a control in the bottom, and that you click on a link to select some data for example , which are dispalyed in a different view of the multiview.

How to apply/change CSS dynamically


Following is the sequence of Screenshot which depicts how the css is toggled dynamicaly using javascript. The CSS of the element is changed dynamicaly using javascript fuction.

HTTP Post from SilverLight application to a REST Service


  1. How to create REST service for JSON request and response format.
  2. How to create SilverLight Client, which will consume a REST service on JSON data format.
  3. How to POST data in JSON format from SilverLight client.

Using the AnyButton to Create Dynamic Image Buttons


We've all had that problem - designing our web sites to have a certain look and feel. Unfortunately, not every visitor will view the site the way you intended. This is due to the fact that different operating systems render native browser controls differently. The buttons in OS X have the aqua look while the buttons in Windows 2000 look gray and outdated.

Nested Repeater : Display hierarchal data in web form by using ASP.Net repeater


This below code shows how to display hierarchal data from multiple tables by using ASP.Net repeater control. This article shows hierarchal data from Categories, Products, Orders and Order Details tables of Northwind database.

ASP.Net Page Navigation using Workflow 4.0



In this Article, how Workflow 4.0 can be used to control page navigation in ASP.Net is explained. If you are new to workflow 4.0 please go through MSDN documentation to understand how it works since the scope of this article is limited to workflow creation.

How to show Alert and Confirmation Message box in ASP.NET

In this Article Beginners can learn how to display a Message Box in using JavaScript.

1. Alert Message Box:

This type of Message Box is used to give Alert Information to the User.This can be done by using 'alert' method. Use the Alert method in <script> </script> tags by using a function with method name. Call this function On 'Client click event in Button as follows in Below code.

Working with CSS


Cascading style sheets give we more control over the appearance and presentation of your pages. Using cascading style sheets, we can extend the ability to precisely specify the location and appearance of elements on a page and create special effects.

Manage Ads with AdRotator Control in ASP.NET 2.0


The AdRotator control available in ASP.NET 2.0 allows you to manage and run ads on a website. The ads can be image files (gif, jpg etc) only. The AdRotator control selects and displays an ad randomly each time a page is refreshed. The selection of the ad is done based on the priority you define in the ad settings file.

Outlook with .NET 2.0


Outlook Object Model Overview

For accessing the outlook and its features you have to add reference of Microsoft Outlook 11.0 object library Version 9.2 (COM component) to your project.This COM component provides various objects through we can access the outlook.

On-line Address Book in ASP.NET 2.0


This is an On-line Address Book project. Those who are new to ASP.NET or going for first project can learn a lot from this. This is a project to keep the address and other information. In our daily life we meet many people and we have to keep the information and addresses of these people. This project is very useful to keep the record.

Calling WCF Duplex service in Silverlight


In a typical Silverlight application, a client web service requests a web service and waits for the response from the service and then processes it. This is distinctly a one way communication, in which a client must initiate every conversation.

ImageMap control in and Defining Hot Spots for it


ImageMap is a server side control, which allows you to display an image and take an action when a particular part of the image is clicked. Think about that; you are working on a Car sales website for a reputed car manufacturing company. And, your client asks to display a nice picture of your car model in one page and when the user clicks the parts of it (the car), the details about the part is displayed on the next page. ImageMap will fulfill this need.

Read All Notepad Files in a folder and merge all notepad files DATA in . aspx page

In this article, trying to fetch data more notepad file’s of a folder and merge them on an aspx page. In this sample article 45 notepad files are used, firstly read them and then merge all files and write on a .aspx page. It’s a fast way to assemble all files to in a one webpage. 

Optimizing Crystal Reports for Asp.Net


Implementing and embedding Crystal Reports in the .Net environment is extremely easy to do. Once the tools are downloaded from the businessobject website creating and editing reports from Visual Studio is a breeze. We are going to be covering the caching functionality that the Crystal Report framework provides through the ICachedReport interface.

Extension Methods in C#


Extension methods make it possible to write a method to a class that doesn't offer the method at first. You can also add a method to any class that implements a specific interface, so multiple class can make use of the same implementation.

Adding Cloud Service project to existing ASP.Net Web Application


Imagine that we are moving an existing Web Application or ASP.Net MVC Web Application to cloud. In that case we need to add cloud service to an existing Web Application or ASP.Net MVC Web Application.
We have a solution for Web Application as below.
Now right click on the solution and add a new project in the same solution. Choose Windows Azure project from the installed template and then choose a ASP.Net Web Role.
In role selecting window do not select any role and click on Ok. See the image below.
Now you can see in solution explorer that a Windows Azure project is being added.
After creating a Windows Azure project we need to associate an ASP.Net Web Application project to Window Azure. So to do so, right click on Roles in Windows Azure Project and select add and then choose Web Role Project in solution option.
Then you will get the project in the solution. Press ok.
On clicking of Ok, Visual studio will update csdef and cscfg file for the Web Role.


How to Access/Manipulate HTML Elements/Javascript in Silverlight


Interacting between HTML and ASP.NET has been one of the most common coding scenarios we have come across; i.e. accessing HTMLl elements and calling JavaScript from code behind.To add Silverlight content to an existing page and allow the HTML and Silverlight portions of the page to interact.

When we need this interaction: So let us see initially what could be probable scenarios where we need to interact / access HTML in Silverlight page.
  1. To make compatible: When we want to use the latest and greatest user interfaces with Silverlight, this requires compatibility with HTML. Situations could be like including a Silverlight content region to show non-essential extras alongside the critical HTML content.
  2. Legacy web pages: If we have an existing web page that does exactly what we want, it may make more sense to extend it with a bit of Silverlight pizzazz than to replace it outright. So the solution is to create a page that includes both HTML and Silverlight content.
  3. Server-side features: We know that Silverlight is a poor fit for tasks that need to access server resources or require high security, which is why it makes far more sense to build a secure checkout process with a server-side programming framework like ASP.NET. But you can still use Silverlight to display advertisements, video content, product visualizations, and other value-added features in the same pages.

So, let's try to BRIDGE this gap between Silverlight and the ordinary world of HTML.

What is this BRIDGE: This BRIDGE is built using a Silverlight set of managed classes (commonly called Helper classes) that replicate the HTML DOM (document object model), and we can access these classes by namespace, System.Window.Browser.

What are these Classes and what they do?


Ok, so let's start using these classes to interact with HTML from Silverlight page.

Step 1: Create a Silverlight application and name it BrowserInteraction.

Step 2: Open main.xaml; in this project we will use multiple classes so to demonstrate each functionality; we will create a listbox to display functionality and a border to see the result.

Step 3: Create a Listbox and a border (Border is a content control, so we call show control which will display result), so the xaml looks like this:
<Grid x:Name="LayoutRoot">        <Grid.RowDefinitions>            <RowDefinition Height="*"></RowDefinition>            <RowDefinition Height="Auto"></RowDefinition>            <RowDefinition Height="3*"></RowDefinition>           
        <ListBox x:Name="lst" SelectionChanged="lst_SelectionChanged">            <ListBoxItem Content="BrowserInfo"></ListBoxItem>            <ListBoxItem Content="ReadHTMLtag"></ListBoxItem>            <ListBoxItem Content="PlayWithHTMLElement"></ListBoxItem>        </ListBox>      <controls:GridSplitter Margin="0 3 " HorizontalAlignment="Stretch" Height="2"                             Grid.Row="1"                             ></controls:GridSplitter>        <Border BorderBrush="SlateGray" Grid.Row="2" x:Name="PagePlaceholder" BorderThickness="2"                Background="AliceBlue"                ></Border>    </Grid>
Step 4: Add silverlight page as a new element. Here we will use it to show browser information.

Write this xaml;
<UserControl x:Class="BrowserIntegration.BrowserDetail"    xmlns=""
    Width="400" Height="300"  Loaded="UserControl_Loaded">
    <Grid x:Name="LayoutRoot" Background="White" Margin="10">        <TextBlock x:Name="lblInfo" TextWrapping="Wrap" ></TextBlock>    </Grid></UserControl>

Step 5: In browserdetail.xaml.cs, add namespace
using System.Windows.Browser

Step 6: Write handler for UserControl_Loaded
 private void LayoutRoot_Loaded(object sender, RoutedEventArgs e)
     BrowserInformation b = HtmlPage.BrowserInformation;
     lblInfo.Text = "Name: " + b.Name;
     lblInfo.Text += "\nBrowser Version: " + b.BrowserVersion;
     lblInfo.Text += "\nPlatform: " + b.Platform;
     lblInfo.Text += "\nCookies Enabled: " + b.CookiesEnabled;
     lblInfo.Text += "\nUser Agent: " + b.UserAgent;
Step 7: Go back in mail.xmal.cs and write a handler for listbox to call Browserdetail.xaml.
private void lst_SelectionChanged(object sender, SelectionChangedEventArgs e)
     string newpage = ((ListBoxItem)e.AddedItems[0]).Content.ToString();
     Type type = this.GetType();
     Assembly asm = type.Assembly;
     UserControl Page = (UserControl)asm.CreateInstance(type.Namespace + "." + newpage);
     PagePlaceholder.Child = Page;

You can also use Navigation framework to call other Silverlight page.