NUnit - Unit Testing framework for MS .NET

Sunday, April 26, 2009


What is NUnit ?


NUnit is an open source unit testing framework for Microsoft .NET. It was actually ported from JUnit.


What it's developers say?


"Initially ported from JUnit, the current production release, version 2.4, is the fifth major release of this xUnit based unit testing tool for Microsoft .NET. It is written entirely in C# and has been completely redesigned to take advantage of many .NET language features, for example custom attributes and other reflection related capabilities. NUnit brings xUnit to all .NET languages."


From where can I download?


http://www.nunit.org/index.php?p=download


Test Runners:-


1. Console Runner(nunit-console.exe).


2. GUI Runner(nunit-gui.exe).


For more information see,


http://www.nunit.org/index.php?p=home



Mono - The .NET development platform

Thursday, April 23, 2009

What is Mono?
It is an Cross-platform, Open Source .net development framework.

Novell is giving the sponsorhip for it. The objective is to enable UNIX developers develope cross platform .NET applications. The latest version is Mono 2.4.

The Components:
1. C# compiler
2. Mono Runtime
3. Base Class Library
4. Mono Class Library

How to download?
Goto the http://mono-project.com page and from there you can download

For more information :
http://mono-project.com

Description about Out of Box Libraries

Wednesday, April 22, 2009


Description about  Out of Box Libraries

What is a document library?

A document library is where you upload your core documents. They consist of a row and column view with links to the documents. When the document is updated so is the link on your site. You can also track metadata on your documents. Metadata would consist of document properties.

What are picture libraries?

Picture libraries allow you to access a photo album and view it as a slide show or thumbnails or a film strip. You can have separate folder for each event, category, etc.

What is a Slide library?

The SharePoint Slide Library is a feature that comess with MOSS only. It provides rich integration with the PowerPoint 2007 client to track slides used from the library in a presentation to ensure that updates to the master slide are notified to users of the slides

 

How to create Slide library?

 

. To create a Slide Library, you need to have at least Designer permissions.

1.       On the Site Actions menu, click  View all site content

 

  1. Clcik Create button      
  2. Under Libraries, click Slide Library.

     

             Note:    Slide Libraries can be created in only certain types of sites, such as a Team site and Document Workspace.   If
                          you  do not see Slide Library under Libraries, the type of site you are working on does not support Slide Libraries.

4.       On the New page, under Name, type a name for the library. The name appears in any navigation links that you set up.

5.       Under Description, type an optional description.

6.       Click Create.

 

How to disable Autocomplete in Asp.net Textbox




Set AutoCompleteType Property to None


Bandwidth monitoring tool

Tuesday, April 21, 2009




Free asp.net hosting sites

Some Good Website collections 1

Sharepoint WebParts for Chart,Datagrid, Maps



Sharepoint WebParts for Chart,Datagrid, Maps

Unit testing Tool for Microsoft SharePoint



Unit testing Tool for Microsoft SharePoint



Sharepoint Server Download

Microsoft Office SharePoint Server 2007 Trial Version






Location of CAML


Location of CAML

CAML, the XML-based language used throughout SharePoint Team Services from Microsoft, is implemented in schemas and HTML files in the wwwroot and web server extensions folders of a SharePoint team Web site. The contents of the web server extensions folder represent global settings on the server and provide templates for creating new sites, while the contents of the wwwroot folder are used at run time and represent a specific instance of a site.

The following directories are the primary locations of files where you can edit CAML:

  • List of Lists table (tp_Fields column) and Views table (tp_View column) in the server database — Contain metadata that describes lists and views.
  • Inetpub\wwwroot\_layouts — Contains general purpose forms used to create new views or lists and to modify site settings at the site's top level.
  • Inetpub\wwwroot\Lists — Each subfolder contains HTML files that are used in forms for creating or modifying a specific list on a team Web site.
  • Inetpub\wwwroot\Shared Documents\Forms — Contains HTML files that are used in forms for document libraries.
  • Program Files\Common Files\Microsoft Shared\web server extensions\50\Templates\1033\Layouts — Contains HTML template files used for creating the forms that are instantiated in the _layouts folder of wwwroot. Each subfolder in the Layouts folder in turn contains a SCHEMA.XML file that serves as a template for defining the fields, forms, and views of the given list represented by the subfolder. Each of these folders also includes HTML files that apply CAML.
  • Program Files\Common Files\Microsoft Shared\web server extensions\50\Templates\1033\xml — Contains the five core XML schemas that provide basic definition of types. The following table describes these files that are used in schema definition.
    Schema Description
    BASE.XML Defines the schema for built-in base types for lists.
    DOCICON.XML Used for mapping file extensions to particular icons.
    FLDTYPES.XML Defines how field types are rendered.
    ONET.XML Defines the schema for built-in base types of lists.
    STDVIEW.XML Defines the base view used when creating new views.

In addition to the locations listed here, you can also add CAML data islands directly to HTML files on the team Web site. The CAML ows: namespace must be specified in the containing element for the data island.

Note   The Program Files\Common Files\Microsoft Shared\web server extensions\50\Templates\admisapi folder contains files used in administration of the site. CAML is not used in these files and their contents should not be altered.

Caution   Changes to files in the web server extensions \...\Templates folder can break functionality in SharePoint Team Services. It is recommended that you make any changes on a test server first and then copy the final files to a production server.


Basics of MOSS


What is MOSS?

Microsoft Office SharePoint Server (MOSS) 2007 is a portal-based platform built over Windows SharePoint Services (WSS) 3.0. It organizes and aggregates an organization's information in one central, web-based application. MOSS enables users to create portals, has enterprise-level services, such as business intelligence and business process integration, etc.

 

What is it used for?

It is primarily used for Content Management, Collaboration, organizing and aggregating an enterprise's data into web-based portal. For e.g. Knowledge Management Portal.

 

Advantages:

Many built-in features, Rich Security, Content Management, Integration with Office products, business process can be integrated with workflows, less effort to create basic sites with standard functionalities such as search etc.

 

Hierarchy:

Web Application -> Site Collection -> Sites->database (Content db, Config db, SSO db). An interesting point to note here is that the equivalent of .Net website here is Web Application and not the sites under site collection.  Also the databases are encrypted hence developers can't view data.

 


Sharepoint Minimal Master Page from MS

DataConnections in InfoPath 2007- Part I

Monday, April 20, 2009

What is InfoPath?

Infopath is a very powerful Form Designer. One of the major advantages of InfoPath is, it is wholely XML-based and the form design is based on XSD. Infopath 2007 comes with MS Office 2007.

What is Form Template and Form Data?

Form Template is nothing but the Form Design. Form Data is what we store through the Form.

Data Connections

It is the connection to Data Source. They allow to do read, write operations over the Data Source. There are many types of connections in InfoPath. They are :

1. SQL Server

2. Web Service

3. XSD

4. XML

5. Data Connection Library (DCL)

6. E- mail

7. SharePoint Document Library

The objective of this topic is to explain “How to work with DataConnections in InfoPath 2007”. So, We are not going to discuss the basics of InfoPath in detail.

We are going to see here a sample in a step by step manner , which shows you the basic of Data Connection in InfoPath. Here InfoPath is the front-end and MS Sql Server 2005 is the back-end.

A sample displaying an Employee Information from the back-end

Let us see the sample in a step by step manner with back-end and fron-end flow.

Back-end (SQL Server):

We are creating a PayRoll Database for this sample. You can either create this database or use your existing database. But you need to create the following Employee table.

The code to create employee table:

CREATE TABLE [dbo].[Employee](

[EmpId] [bigint] IDENTITY(1,1) NOT NULL,

[EmpName] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,

[DOJ] [datetime] NOT NULL,

[Designation] [nvarchar](25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,

[Department] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,

[Salary] [money] NOT NULL,

CONSTRAINT [PK_Employee] PRIMARY KEY CLUSTERED

(

[EmpId] ASC

)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY]

Code to insert data into the table:

INSERT INTO [Employee]([EmpName],[DOJ],[Designation],[Department],[Salary])

VALUES ("Bill Gates","01/01/1983","CEO","Computers","12222222.0000")

Simillarly insert few records.

Front-End (InfoPath):

Step 1 : Start InfoPath

Click Start > All Programs > MS Office > MS InfoPath 2007 as show in Fig. 1

Step 2: Decide Way of Designing

You will be shown a ‘Getting Started’ Window as shown in Fig. 2.

Click on Design a Form Template.

Step 3: Select Template

Select Database , Check whether “Enable browser-compatible features only” is checked. If not then check it. Form Template Option button will also bet selected. Then Click Ok.

Step 4: Select Database

Data Connection Wizard will be shown .

Click on Select Database.

Double click on +NewSQLServerConnection

Enter the server name.

Select “Use Windows Authentication”

Click Next.

Choose PayRoll database from the combo box.

Select Employee table , then Click Next.

Click on Finish.

Select desired fields there in this screen.

Click Next

Click Finish in the next Screen.

Step 5: Design Form

Expand the queryFields in the DataSource Window.

Then Drag EmpId into the form and drop into “Drag query fields here” area.

Simillarly expand dataFields and drag remaining fields into “Drag data fields here” area.

Then the resultant form will look like in the Fig.10

Now the Form creation and data connection is over. That’s all the database form generation.

The final step is to test the Form we created above.

Step 6: Running and Testing the Form

Click Preview in the toolbar.

Enter 1 in the EmpId field.

Click Run Query.

A security screen will be shown, click Yes in it. After that the form will fetch the corresponding values for the empId “1”, as shown in the following diagram. You can test with your desired values and it will display the result.

Click Close Preview to exit.

Have fun creating forms.

Purpose and Usage of Partial Class

Purpose and Usage of Partial Class

What is a Partial Class (or struct or interface)?
A partial class is a feature in which you split a class definition into two or more files. All the parts are joined together when the application is compiled.

Situations on which it can be used:
When multiple programmers need to work on a same class then Partial class is an obvious choice.
Conditions:
All files should use Partial keyword
All files should be available at compile time
All files should have same scope specifies.

On which it cannot be used:
It can’t be applied on delegate or enumeration.

An Example:
Let us consider an example where we have 3 .cs files one for educational marks, one for sports marks and one for Cumulative marks and average of a student. A single class name Marks is split across these three .cs files respectively.

1. Create a Visual Studio Windows Application Project.
2. Then add 3 .cs files with the following names respectively EducationMarks.cs, SportsMarks.cs, and Cumulative.cs.

The three .cs files used in the example are:
EducationMarks.cs
SportsMarks.cs
Cumulative.cs

The Marks class is split into the three .cs files. The three .cs files are given below with explanations.

EducationMarks.cs
This class has an integer variable eduMarks in it. There is one method to set value to the eduMarks called setEducationMark and one method to get value from the variable called getEducationMark.

using System;
using System.Collections.Generic;
using System.Text;
namespace PartialSamp
{
partial class Marks
{
int eduMarks;
public void setEducationMark(int em)
{
eduMarks = em;
}

public int getEducationMark()
{
return eduMarks;
}
}

}

SportsMarks.cs
This class has an integer variable sportMarks in it. There is one method to set value to the sportMarks called setSportsMark and one method to get value from the variable called getSportsMark.

using System;
using System.Collections.Generic;
using System.Text;

namespace PartialSamp
{
partial class Marks
{
int sportMarks;
public void setSportsMark(int spm)
{
sportMarks=spm;
}

public int getSportsMark()
{
return sportMarks;
}

}
}

Cumulative.cs
This class is the one which sums the sports and educational marks to get the total and then finds the average out of it.

using System;
using System.Collections.Generic;
using System.Text;

namespace PartialSamp
{
partial class Marks
{
int totMarks;
float avg;
public int getTotMarks()
{
totMarks = sportMarks + eduMarks;
return totMarks;
}
public float getavgMarks()
{
return totMarks/2;
}
}
}

Note:
You can even find the intellisense of the methods of prior .cs files in the current files. For example after typing the EducationMarks class, you will get the methods in it being populated in intellisense in the SportsMarks and Cumulative classes.
Visual Design:
Create 4 text boxes and 4 labels and a button. Name them as shown in the Figure 1. Then type the following code in the button1_click,

private void button1_Click(object sender, EventArgs e)
{
Marks m = new Marks();
m.setEducationMark(int.Parse ( txtEM.Text ) );
m.setSportsMark(int.Parse(txtSM.Text));

txtTM.Text = m.getTotMarks().ToString() ;
txtAvg.Text = m.getavgMarks().ToString();
}

Similarly you can try with struct and interface.

What is use of CAPTCHA

Sunday, April 19, 2009

What ?
It is a random generated feature using which you can avoid automated filling , programs etc.

Why?
It is used to verify User Authentication ( in the sense that the user is doing the thing instead of a program)

For more information see,

Captcha

Visual Studio 2010

Enhanced User Experience
SharePoint Development in Visual Studio 2010
Democratizing Application Lifecycle Management
Inspiring Developer Delight
Cloud Development
Web Development

For more information see,

Visual Studio 2010

Ecommerce Payment Gateways

www.paypal.com
www.e-gold.com
http://www.cybersource.com

Free & Easy Access to PCs from Anywhere

Saturday, April 18, 2009

 

www.LogMeIn.com

 

A function to remove the cache problem with ftp

 

Public Function SaveReadMeFile(ByVal host As String, ByVal ftpusername As String, ByVal ftppassword As String, ByVal localpath As String)

Dim cp As New Cache.RequestCachePolicy(RequestCacheLevel.NoCacheNoStore)

'Create a request

Dim URI As String = host

Dim ftp As System.Net.FtpWebRequest = CType(System.Net.FtpWebRequest.Create(URI), System.Net.FtpWebRequest)

'Set the credentials

ftp.Credentials = New System.Net.NetworkCredential(ftpusername, ftppassword)

'Turn off KeepAlive (will close connection on completion)

ftp.KeepAlive = False

'we want a binary

ftp.UseBinary = False

'Define the action required (in this case, download a file)

ftp.Method = System.Net.WebRequestMethods.Ftp.DownloadFile

ftp.CachePolicy = cp

'If we were using a method that uploads data e.g. UploadFile

'we would open the ftp.GetRequestStream here an send the data

'Get the response to the Ftp request and the associated stream

Using response As System.Net.FtpWebResponse = CType(ftp.GetResponse, System.Net.FtpWebResponse)

Using responseStream As IO.Stream = response.GetResponseStream

'loop to read & write to file

Using fs As New IO.FileStream(localpath, IO.FileMode.Create)

Dim buffer(2047) As Byte

Dim read As Integer = 0

Do

read = responseStream.Read(buffer, 0, buffer.Length)

fs.Write(buffer, 0, read)

Loop Until read = 0 'see Note(1)

responseStream.Close()

fs.Flush()

fs.Close()

End Using

responseStream.Close()

End Using

response.Close()

End Using

Return True

End Function

 
 
'''how to use the function
 
 

Dim tmp As Boolean = False

tmp = Me.SaveReadMeFile(vsFtpZipPath & vguid & "/out/readme.xml", vftpUsername, vftpPassword, vsLocalZipPath & "readme.xml")


Downloading a file from ftp



'DOWNLOAD xml file FROM WEB(FTP) to the local folder

My.Computer.Network.DownloadFile(vsFtpZipPath & vguid & "/synchronization.zip" , vsLocalZipPath & "\" & "synchronization.zip", vftpUsername, vftpPassword)

SSL Links

Types of NLB


Acceleration Algorithms Supported:

  • Fastest response
  • Least connections
  • Round robin
  • Weighted round robin

Persistence Methods Utilized:

  • Cookies
  • Sticky connections
  • Header match rules

LINQ to Oracle

what diff between asp.net wesite and asp.net web application






Difference between asp.net website and application

How do I raise a keypress event programatically inside of a controls key event?

http://www.pinvoke.net/default.aspx/user32.SendMessage

http://www.developerfusion.co.uk/show/34/3/

Solution for Long Delay on First Request to ASP.NET 2.0 Application

http://blogs.msdn.com/jamesche/archive/2008/01/08/update-on-slow-startup-fix.aspx
post regarding slow startup of ASP.NET 2.0 applications
online automated system.

External JS reference

usually use the following code to reference an external JavaScript file and it works fine with ASP. NET 1.1, hope it works fine with you.

Page.RegisterClientScriptBlock(string key, string script);

This peace of code register a client side JavaScript block with "Script Key" (If this is already registered then previous f.js file will be replaced) and script -- external file that is referenced.

if(Page.IsClientScriptBlockRegistered(string key))

this peace of code checks if script block is registered or not.

after that JavaScript fucntion can be called from the C# code, some what like this.

button1.Attributes.Add("onClick", "javascript:return function name();");

Scheduling webpart

http://www.componentsource.com/features/calendar-schedule/sharepoint/index.html

Disable Prompt on File download

Response.AddHeader("content-disposition", "inline; filename=AppraisalView.txt")
Response.ContentType = "text/plain"
Response.WriteFile("C:\Inetpub\wwwroot\TestApp\AppraisalView.txt")
Response.Flush()
Response.End()

windows services

http://www.developer.com/net/csharp/article.php/2173801


http://articles.techrepublic.com.com/5100-3513-5784748.html

world time web service

http://www.quantumsoftware.com.au/ProductsServices/WorldTimeWebService.aspx

Free UML tool

www.tracemodeller.com

Analysis Tools

NDepend (www.ndepend.com)
Powerful quite complex (and slow) but not free. If you don't pay for it you cannot export anything.
It supplies a great code query feature, but you can't really take advantage of it without a license.

Dependency Structure Matrix PlugIn for .NET Reflector (http://tcdev.free.fr/ )
This is really cool and it's free! Much easier then nDepend in evaluating dependency structure indeed it's definitely faster.

Source Monitor (http://www.campwoodsw.com/sourcemonitor.html)
Free and easy. Can be used in order to calculate metrics that can be exported to XML.

VisualStudio 2008 Code Analysis or FxCop
Depending on the environment you are currently in you can use MS FxCop or its integration with Visual Studio 2008.

DevAdvantage (http://www.anticipatingminds.com/content/Products/devAdvantage/devAdvantage.aspx )
If you are dealing with .NET 1.1 and Visual Studio 2003 this tool can help analyzing code (also for naming convention). It can also be used in order to automatically correct violations.
Anticipating Minds it's not doing business anymore, so devAdvantage it's now free.
At present we haven't really used it. Maybe when we'll play the build phase of the project.

CodeIt.Right (http://submain.com/?nav=products.cir)
Similar to DevAdvantage but also available for the .NET 2.0 environment. The tool is now at the beta stage.
Same thinking as for DevAdvantage: I cannot say much of it.


Compuware DevPartner Studio ( http://www.compuware.com/solutions/default.htm)
Last but not least DevParter Studio.
Simply the best! It's not really code analysis, but performance analysis (that I think it's essential in an architecture assessment).
I've used it on the .NET 1.1 platform and I know that the last edition added many features like Memory Analysis, Source Code Review, Error Detection and Diagnosis.

.NET Technical Links 1

http://www.csharp-station.com/Tutorials/Lesson14.aspx
www.codeproject.com
www.codezone.com
www.asp.net
www.codeplex.com
www.dotnet2themax.com
www.interfaceconcepts.com
www.developeriq.com
http://pcquest.ciol.com
www.4guysfromrolla.com
https://mcp.microsoft.com/mcp/benefits/Default.mspx
http://www.csharp-station.com

How to fix Error on Paging in datagrid

Friday, April 17, 2009

If you set AllowPaging="true" or AllowSorting="true" on a GridViewcontrol without using a DataSourceControl DataSource (i.e.SqlDataSource, ObjectDataSource), you will run into the followingerrors:



When changing the page on the GridView control:



TheGridView 'GridViewID' fired event PageIndexChanging which wasn'thandled.



When clicking a column name to sort the column on theGridView control:



The GridView 'GridViewID' fired event Sorting whichwasn't handled.



As a result of not setting the DataSourceID propertyof the GridView to a DataSourceControl DataSource, you have to add eventhandlers for sorting and paging.



OnPageIndexChanging="gridView_PageIndexChanging"OnSorting="gridView_Sorting" runat="server" />



private stringConvertSortDirectionToSql(SortDirection sortDireciton)

{

stringnewSortDirection = String.Empty;



switch (sortDirection)

{

case SortDirection.Ascending:

newSortDirection = "ASC";

break;



case SortDirection.Descending:

newSortDirection = "DESC";

break;

}



returnnewSortDirection

}



protected void gridView_PageIndexChanging(objectsender, GridViewPageEventArgs e)

{

gridView.PageIndex =e.NewPageIndex;

gridView.DataBind();

}



protected voidgridView_Sorting(object sender, GridViewSortEventArgs e)

{

DataTable dataTable = gridView.DataSource as DataTable;



if(dataTable != null)

{

DataView dataView = newDataView(dataTable);

dataView.Sort = e.SortExpression + " " +ConvertSortDirectionToSql(e.SortDirection);



gridView.DataSource= dataView;

gridView.DataBind();

}

}

Nullable Types in .net

Wednesday, April 1, 2009

C#

DataTime? dtfromdt= null;

int? intCount = null;

bool? bStatus = null;

VB.NET



Dim dtfromdt As Nullable(Of DateTime)

Dim intCount As Nullable(Of Integer)

Dim bStatus As Nullable(Of Boolean)

Nullable Types in .net

C#

DataTime? dtfromdt= null;

int? intCount = null;

bool? bStatus = null;

VB.NET



Dim dtfromdt As Nullable(Of DateTime)

Dim intCount As Nullable(Of Integer)

Dim bStatus As Nullable(Of Boolean)

LinkWithin

Blog Widget by LinkWithin

Recommended Books