Saturday, March 3, 2007

Install assembly into Global Assembly Cache

Option One

Step One add the sn.exe to External Section of VS2005

1. Click on Menu->Tools->External Tools
2. A window with all external tool listed will popup.. click on add button
3. In title type “String Name tool”
4. In command brows for sn.exe tool [Generally in the bin directory of your sdk folder]
5. Check the use output window and prompt for argument check box…
6. Click on apply to dismiss the widow…

Now you can see that in tools menu you will have a menu item named “Strong Name Tool”. Click on the menu will launch a window asking the argument …. In the argument text box type

–k “c:\\mykeypair.snk”Click on okey to dismiss the window… in output window you will see that successful keypart creation message will be shown…

Your key is reated but not yet associated with any

Adding the key to the project to associate with assembly1. Open your project…
2. Open the property of the project…
3. You will see a tab called signning is bottom of the window… click on the signning button
4. In siginning tab check the sign the assembly check box.
5. In choose a strong name key file … click on brows …. And brows for your mykeypair.snk file…
6. save the project and build it…

That’s it your assembly is strong name signed on….

Option Two [Too Easy]

1. Open your project…
2. Open the property of the project…
3. You will see a tab called signning is bottom of the window… click on the signning button
4. In siginning tab check the sign the assembly check box.
5. In choose a strong name key file … click on new…
6. A window asking for snk file will popup… type the desiered name and click on okey to dismiss the window… save the project and build it…

That’s it your assembly is strong name signed on….

Deploy the assembly in GAC…

1. Add the gacutil.exe tool just like the sn.exe tool
2. Now open the gacutil tool from tools….
3. In the argument window type….
4. -i "$(ProjectDir)\bin\debug\DataBaseHelper.dll" or [-I “yourprojectdir\buildmode[debug or release]\bin\filename.dll”]
5. Click on okay to dismis the window..
6. In output window you will see a successful message….
7. “Assembly successfully added to the cache”

Happy programming!

Monday, February 19, 2007

CSS Problem of Ajax Tool Kit Calendar

AjaxControlTookKit is a very nice addition of Asp.net 2.0 Ajax Extension. Recently I had very nice experience using asp.net 2.0 Ajax in few of my projects. "update panel" is very use full control as far as easy Ajax is concern. I haven't explored the whole area of client side scripting, but so far the experience with the server side controls are pretty much good and satisfactory.

Problem with Calender

In one of my project, I had to use the Calendar Extender of Ajax. Well in the page level the Calender Extender worked fine. but when i put the extender in one of my usercontrol. after the page render in browser the calender popup's position is pretty strange. No deterministic behavior was found in popup. when I click on the button of the calender the popup window appeared way up where it should actually show.


I went on trying few things to fix the thing and succeed on the setting position to relative. I just put the position behavior of the parent div of the Extender to relative.


style="position:relative"

worked like cramp

Another problem

If you set the css property of the calender extender suddenly the calender loose all its default behaviour and color skim. And no detail guide line is found in the ajax.asp.net site for customizing the style of the calender control.


Since ajaxControlToolKit is under development we hope this issues will be fixed in the actual release product.

Thursday, January 25, 2007

VS templates not working? Easy to get things back.

Recently I had to work with window SharePoint Service 3.0 and its development. I download the visual studio 2005 project templates for SharePoint development. I downloaded the project msi from Microsoft download site.

http://download.microsoft.com/download/e/8/a/e8aa8476-5af6-4f38-aed2-0247a99d2bc6/VSeWSS.msi

Installed in my local computer… but when I opened the IDE2005 project templates are not there…..

I got confused… and try reinstall the msi… but noting happed… I went to google and found few people is also suffering from this problem… the problem is my vs2005 is installed in different drive other that “c:\” and the installed temples are in default “c:\”… and then I moved my template in the drive where the IDE2005 is installed….

Location of the project templates is [your dive letter]:\Program Files\Microsoft Visual Studio 8\Common7\IDE…

There were two directories one if project template and other is item template… last thing that I did is to make ide identity the project templates….

For this I had to just a command in vs2005 comma prompt..

devenv /installvstemplates

I found help from the following forum… please go there for more detailed discussion…

http://geekswithblogs.net/ehammersley/archive/2005/11/08/59451.aspx

Hope this will help someone someday….

Friday, January 5, 2007

Bubble Sort

Introduction

Bubble sort, also known as sinking sort, is a simple sorting algorithm that works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items and swapping them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted. The algorithm gets its name from the way smaller elements "bubble" to the top of the list. Because it only uses comparisons to operate on elements, it is a comparison sort. Although the algorithm is simple, it is not efficient for sorting large lists; other algorithms are better.

Pseudo Code

The pseudo code of the bubble sort is given bellow.

procedure bubbleSort( A : list of sortable items )
repeat
swapped = false
for i = 1 to length(A) - 1 inclusive do:
if A[i-1] > A[i] then
swap( A[i-1], A[i] )
swapped = true
end if
end for
until not swapped
end procedure


Complexity


Bubble sort has worst-case and average complexity both О(n2), where n is the number of items being sorted. There exist many sorting algorithms with substantially better worst-case or average complexity of O(n log n). Even other О(n2) sorting algorithms, such as insertion sort, tend to have better performance than bubble sort. Therefore, bubble sort is not a practical sorting algorithm when n is large.


The only significant advantage that bubble sort has over most other implementations, even quicksort, but not insertion sort, is that the ability to detect that the list is sorted is efficiently built into the algorithm. Performance of bubble sort over an already-sorted list (best-case) is O(n). By contrast, most other algorithms, even those with better average-case complexity, perform their entire sorting process on the set and thus are more complex. However, not only does insertion sort have this mechanism too, but it also performs better on a list that is substantially sorted (having a small number of inversions).


Simulation


Simulation #1:


image


Video


 


More online simulation



Implementation


Implementations of the bubble sort is given bellow. For now we have only three supported language, in future we would try to incorporate more implementations.


Code Sample in “c”


Real implementation in c is given bellow.


#include<stdio.h>  
#include<conio.h>

void bubble(int a[],int n)
{
int i,j,t;
for(i=n-2;i>=0;i--)
{
for(j=0;j<=i;j++)

{
if(a[j]>a[j+1])
{
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}


}//end for 1.

}//end function.


void main()
{
int a[100],n,i;

clrscr();

printf("\n\n Enter integer value for total no.s of elements to be sorted: ");
scanf("%d",&n);

for( i=0;i<=n-1;i++)
{ printf("\n\n Enter integer value for element no.%d : ",i+1);
scanf("%d",&a[i]);
}

bubble(a,n);

printf("\n\n Finally sorted array is: ");
for( i=0;i<=n-1;i++)
printf("%3d",a[i]);

} //end program.


Code Sample in “c++”


Bellow a simple implementation of bubble sort in c++ is given.


#include <stdio.h>
#include <iostream.h>

void bubbleSort(int *array,int length)//Bubble sort function
{
int i,j;
for(i=0;i<10;i++)
{
for(j=0;j<i;j++)
{
if(array[i]>array[j])
{
int temp=array[i]; //swap
array[i]=array[j];
array[j]=temp;
}
}
}
}

void printElements(int *array,int length) //print array elements
{
int i=0;
for(i=0;i<10;i++)
cout<<array[i]<<endl;
}


void main()
{
int a[]={9,6,5,23,2,6,2,7,1,8}; // array to sort
bubbleSort(a,10); //call to bubble sort
printElements(a,10); // print elements
}


Code Sample in “c#”


The c# implementation is given bellow.


namespace AllAlgorithm
{
public class BubbleSort
{
private readonly int[] _samples = new int[100];
private int x;
public void SortArray()
{
int i;
int j;
for (i = (x - 1); i >= 0; i--)
{
for (j = 1; j <= i; j++)
{
if (_samples[j - 1] > _samples[j])
{
int temp = _samples[j - 1];
_samples[j - 1] = _samples[j];
_samples[j] = temp;
}
}
}
}
}
}


References



  1. http://en.wikipedia.org/wiki/Bubble_sort
  2. http://www.sorting-algorithms.com/bubble-sort
  3. http://www.sorting-algorithms.com/

Friday, December 8, 2006

Implementing Xceed GroupRow and Enabling Row Grouping

Xceed Grid of 3.x Version has a very interesting feature Called Grouping. It allows you to show rows in groups and in a horizontal tree structure. Now let’s discuss about how to implement Xceed grid group feature. Well Xceed grouping feature works on columns that is you must group the rows on a particular column, but you can also use recursive grouping.

To add grouping feature first you need to add a Group Object. And we need to set the property “GroupBy”. “GroupBy” property of Group object takes a string as value which represents a column name of the grid. Bellow in code we have a simple example how to add a group by row.

private Xceed.Grid.Group group;

//in declaration section

//in initialization section

grid.Columns.Add( new Column( "DEPT", typeof( string ) ) );

grid.Columns["DEPT "].Title = "Department";

grid.Columns.Add( new Column( "NAME", typeof( string ) ) );

grid.Columns["NAME"].Title = "Employee Name";

group = new Group();

group.GroupBy = "DEPT";

grid.GroupTemplates.Add( group );

grid.UpdateGrouping();

In the above example we have two column name and department. And we want to group employees by department. So groupby property of group object is set to the column name. And last of all you need to add the group object in the grid’s group template and call the update grouping method of the grid to activate the grouping.

Xceed by default adds a group header row. But we can always customize the group header and add our own customized group row. Bellow a simple example is given how to add group header row.

//in declaration section

private Xceed.Grid.GroupManagerRow gmrow;

//in initialization section

gmrow = new GroupManagerRow();

gmrow.Height = 24;

group.HeaderRows.Add( gmrow );

Xceed have GroupMangerRow for this purpose. You must add the GroupMangerRow to the header collection of the group object. And you can customize its Font, Fore Color, Title Format, Back Color, and other properties. Title format is very interesting. By default GroupMangerRow show the assigned groupby row column Title. But we can customize the Group by Header Row Title.

gmrow.TitleFormat = "%GROUPKEY% have %DATAROWCOUNT% Employees";

Here I have used only two keys to customize the Title format of the group header row. Please go to your Xceed Grid help and look for GroupManagerRow.TitleFormat property and look for more interesting feature to customized the group header row title.  

Sunday, November 26, 2006

Asp.net Tree view control, very useful But.

Asp.net 2.0 ships with a whole new set of controls. Navigation controls are one of them. In navigation control we have three options

  1. Sitemap path
  2. Menu
  3. Tree View

TreeView

 

Recently I have worked in a project which is a demo project where I had the pleasure of using the asp.net 2.0 tree view control. Below I will be demonstrating a simple way to use the treeview and some things that we should know while we use tree view control of asp.net 2.0 in our projects.

 

Obviously tree view control has node property and nodes can be create dynamically and modify the node collection on runtime. But it’s for only level one node. For level two nodes node is created just the way it is, but need to add in the child node property. So in a sense tree view has node property and nodes have no recursive node property and to deal with child node, node has child node collection.

 

Constructor of Node class has several overloads. Actually 5 of them are there.

 

TreeNode tn = new TreeNode("Text");

TreeNode tn = new TreeNode("Text", _value);

 

Here we should always be careful about the value property. This value property must be distinct for each collection.

 

For example if we have a Tree Node consists of three Nodes and each and every done has value property as a same value. SelectedNodeChanged even returns always the first node of the collection.

 

TreeNode tn1 = new TreeNode("Node One",-1);

TreeNode tn2 = new TreeNode("Node Two",-1);

TreeNode tn3 = new TreeNode("Node Three",-1);

TreeView1.Nodes.Add(tn1);

TreeView1.Nodes.Add(tn2);

TreeView1.Nodes.Add(tn3);

 

In the web application if we select node three that is tn3 … in SelectedNodeChanged event we will have th1 as SelectedNode. I don’t know how this happened but surely it happened. But if we provide different value in the value field of the node constructor this was okay. Even if we don’t provide any value things work just fine.

 

Tree view has a wide range of configuration and style settings. Among these StaticItemStyle and StaticItemHoverStyle is most useful.

 

Well sometime we need to disable a node in our view. But TreeNode class do not have any enable or disable property, rather it has selection Action Property. We need to set the selection property value to none to make a node disabled.