Knowledge Transfer

Wednesday, December 26, 2007

Good Site For ASP,JAVASCRIPT,SQL SERVER

ASP Introduction,ASP Installations,Basic File in ASP,Explicit declaration of variables,Variable syntax,Getting the variable type,Running Website in PC using IIS ,Advantage Disadvantage of ASP,Tasks ASP Can do,Buffer On or Off in ASP,
Redirection of pages



Happy Coding,

Wednesday, November 28, 2007

How do you add a number of months to a date and then format the output?

###How do you add a number of months to a date and then format the output?###

http://www.irt.org/script/170.htm

### Date Functions ###
http://www.irt.org/script/date.htm


Happy Coding in javascript

How do you add a number of months to a date and then format the output?

### How do you add a number of months to a date and then format the output ###

REF SITE:

Monday, November 26, 2007

sql server books,interview Questions,Faq's

This site is specially for all asp.net,sql server and javascript Tutorials ,books and interview questions available.



Happy Coding,

SQL SERVER 2005 Interview Questions,Tutorials,Faq's

This Site is Specially for all Concepts like in sql server,asp.net and javascript.

Tuesday, November 20, 2007

Email validation in javascript,Regular Expression For Email Address Verification

This script uses regular expressions to check that a form field contains a valid email address. Note that it won't catch all invalid emails, like most similar scripts. However, for most intents and purposes, this script should serve its purpose well, by rejecting common email typos while leaving room for obscure yet valid emails to pass.


http://www.dynamicdrive.com/dynamicindex16/emailvalidate.htm

-------------------------------------------------------------------------------

Does your form contain INPUT box(es) that require a date value from the visitor? Sev's Popup Calendar script allows for a visual, interactive way of selecting and inputting this date, rendering the job of your visitor reaching for a physical calendar to find out the date (whether for today's or otherwise) obsolete. Very practical use of DHTML...

http://www.dynamicdrive.com/dynamicindex6/popcalendar.htm

Ref Site: http://www.dynamicdrive.com

HappyCoding

Sunday, November 18, 2007

Paging in ASP

Some links for ASP pageing ..for Different different Formats.

http://www.codeproject.com/asp/rspaging.asp

Happy Coding

How to call SQL Server stored procedures from ASP

Here one link for Calling Stored Procedure in ASP.both input and output parameters in Sql server Stored Procedure.


http://support.microsoft.com/kb/q164485/

Happy Coding

Automatically send the mail Through Schedular in ASP,ASP.NET,JSP or Any programming

This Code is Helpful when i am sending one Greeting at Specified Date.then that time the Greeting will be Sened o Specific Person Through XMLHttp Object in ASP,ASP.NET.

plz write the this VBS file or ASP File any file like this using XMLHttp Object.
-------------------------------------------------------------------------
Sub MyASPJob()
Dim oXMLHttp
Dim sURL
on error resume next
Set oXMLHttp = CreateObject("MSXML2.XMLHTTP.3.0")
sURL = "http://dev.hydcarpool.com/giftcard/dispatcher.asp"
oXMLHttp.open "GET", sURL, false
oXMLHttp.send()
if oXMLHttp.status = 200 Then
' Retrieve enter HTML response
MsgBox "Job Executed!!!!"
'MsgBox oXMLHttp.ResponseText
else
' Failed
end if
Set oXMLHttp = nothing
End Sub
Call MyASPJob()
---------------------------------------------------------------------------

Here The sURL="http://dev.hydcarpool.com/giftcard/dispather.asp" File Contain the all Email Address For Sending Specific time.

Then Let's Start the Process to put the above "dispatch.vbs" File into Schduler.

ControlePanel--->Scheduler--->add -->add the dispatch.vbs File into Schedular.
For Specific time to execute that File.that's it.

then Automaticay Everyday Schedular is Excuted then that time the "dispather.asp" File is called ...

Happy Coding.

Thursday, November 15, 2007

RFC822_Date Format For RSS and Normal Dates in ASP,.Net,JSP Formats

The Date Formats are Different like dd/mm/yyyy,mm/dd,yyyy, like that some Date Formats are Different.

This is RFC822 Format date Code For Using in RSS Feed.

In ASP Code:
call return_RFC822_Date(NOW(),"GMT")

The Function For Geeting RFC822 Format :


Function return_RFC822_Date(myDate, offset)
Dim myDay, myDays, myMonth, myYear
Dim myHours, myMonths, mySeconds

myDate = CDate(myDate)
myDay = WeekdayName(Weekday(myDate),true)
myDays = Day(myDate)
myMonth = MonthName(Month(myDate), true)
myYear = Year(myDate)
myHours = zeroPad(Hour(myDate), 2)
myMinutes = zeroPad(Minute(myDate), 2)
mySeconds = zeroPad(Second(myDate), 2)

return_RFC822_Date = myDay&", "& _
myDays&" "& _
myMonth&" "& _
myYear&" "& _
myHours&":"& _
myMinutes&":"& _
mySeconds&" "& _
offset
End Function
Function zeroPad(m, t)
zeroPad = String(t-Len(m),"0")&m
End Function


Enjoy the Coding.

Tuesday, November 13, 2007

Menus,PopUps,Image Effect in javascript Use DynamicDrive.com

all types of Calendars, Date & Time ,Document Effects ,Dynamic Content,Iframe & Ajax, Form Effects ,Games ,Image Effects,Galleries, Mouseover, Slideshows ,Links & Tooltips ,Menus & Navigation,CSS Based, Multi-levels ,Mouse and Cursor ,Scrollers ,Text Animations ,User/System Preference ,Window and Frames ,XML and RSS Other



---------------------------------------------------------------------

Full cross-browser compatibility including IE, Netscape, Mozilla, Opera, Firefox, Konqueror and Safari,on Windows, Mac OS and Linux ,Search engine friendly ,Fits for secure HTTPS sites,Section 508 compliant,Support for any doctypes,Menu can be populated from a database using ASP, PHP, etc.

Multiple dhtml menus on the same page
Friendly to other scripts and css styles
Any HTML code can be used within javascript menu items


--------------------------------------------------------------------------
Tabs is your choice! Just divide the information and distribute it among the tabs so that your visitors could reach the next piece of information with one single click






Enjoy with Coding

Tuesday, November 6, 2007

How to Create DLL File in C#.Net or VB.Net

Creating a DLL using Visual C# is piece of cake. Believe me its much easier than VC++. I have divided this tutorial in two parts. 1. Building a Class Library, and 2. Building a client application to test the DLL.


http://www.c-sharpcorner.com/UploadFile/mahesh/dll12222005064058AM/dll.aspx

Happy Coding

Friday, November 2, 2007

Good Site and Blog For Share Point Server 2007 ,WSS

1)
http://www.sharepoint-screencasts.com/

Monday, October 29, 2007

Interview Question in i3-Soft Solutions, Hyderabad.

Process Of Interview:
Machine Test (GridView+Stored Procedure)
Technical Round
Interview Questions :

1)ViewState
2)GridView Operations
3)web.Config
4)what is dataset?
5)Class and Encapsulation
6)Aunthetication and authorization....
7) Session states
8) Delegate and evets

Happy Coding

Friday, October 26, 2007

Function Members,Output,Reference parameters,reference Type,Varible,storage Location in C#.Net

Function member :
A function member is a method, property, event, indexer, user-defined operator, instance constructor, static constructor, or destructor.

Output parameter :
A parameter very similar to a reference parameter, but with different definite assignment rules.
Reference parameter (pass-by-reference semantics) :

A parameter which shares the storage location of the variable used in the function member invocation. As they share the same storage location, they always have the same value (so changing the parameter value changes the invocation variable value).

Reference type :

Type where the value of a variable/expression of that type is a reference to an object rather than the object itself.

Storage location :
A portion of memory holding the value of a variable.

Value parameter (the default semantics, which are pass-by-value) :
A value parameter that has its own storage location, and thus its own value. The initial value is the value of the expression used in the function member invocation.

Value type :

Type where the value of a variable/expression of that type is the object data itself.

Variable :

Name associated with a storage location and type. (Usually a single variable is associated with a storage location. The exceptions are for reference and output parameters.)

Happy Programming,

Ref Site : http://www.developerfusion.co.uk/show/4697/4/

Using Output Parameters in Stored Procedures?

One way to retrieve scalar data in addition to a standard resultset from a stored procedure is to use one or more output parameters. An output parameter is a parameter that is passed into the SQL stored procedure, but whose value can be set in the stored procedure. This assigned parameter, then, is readable back from the application that called the stored procedure.
To use an output parameter you need to indicate that the parameter is intended for output via the OUTPUT keyword. The following snippet shows a stored procedure that returns the set of inventory items through a SELECT statement and uses an output parameter to return the average price:

CREATE PROCEDURE store_GetInventoryWithAveragePrice
(
@AveragePrice money OUTPUT
)
AS
SET @AveragePrice = (SELECT AVG(Price) FROM store_Inventory)
SELECT InventoryID, ProductName, Price, UnitsOnStock
FROM store_Inventory

To access the value of an output parameter from your ASP.NET application you need to create a parameter object whose Direction property is set to Output. After you call the stored procedure the output parameter's value is accessible through the Value property, as the

following code illustrates:
Dim myConnection as New SqlConnection(connection string)
myConnection.Open()
Dim myCommand as New SqlCommand("store_GetInventoryWithAveragePrice", myConnection)
myCommand.CommandType = CommandType.StoredProcedure
'Create a SqlParameter object to hold the output parameter value
Dim avgPriceParam as New SqlParameter("@AveragePrice", SqlDbType.Money)
'IMPORTANT - must set Direction as Output
avgPriceParam.Direction = ParameterDirection.Output
'Finally, add the parameter to the Command's Parameters collection
myCommand.Parameters.Add(avgPriceParam)

'Call the sproc...
Dim reader as SqlDataReader = myCommand.ExecuteReader()
'Now you can grab the output parameter's value...
Dim avgPrice as Decimal = Convert.ToDecimal(avgPriceParam.Value)

(The same issue regarding NULLs applies here as in the previous example...)
You are not limited to a single output parameter; additionally, you can have stored procedures with both input and output parameters.


Refered Site : http://aspnet.4guysfromrolla.com/articles/062905-1.aspx

Thursday, October 25, 2007

Useful website links For MicroSoft Technologies , SqlServer.....

1)Sample Example For asp.net
http://aspnet101.com/aspnet101/tutorials.aspx?id=47

2)
This is for ASP.Net,Windows Application Samples....

http://msdn.microsoft.com/vstudio/tour/vs2005_guided_tour/VS2005pro/Smart_Client/DisplayBusObjectData.htm

3) Assemblies in C#.Net (Private and Shared Assemblies) Links :

http://www.akadia.com/services/dotnet_assemblies.html

4) Input and OutPut parameters in Stored Procedure

http://www.eggheadcafe.com/PrintSearchContent.asp?LINKID=624

5)Object oriented Concets(Encapsulation,Abstraction,Class,Object,Inheritance,Early binding,Late Binding,Interface,Inheritance)
Object oriented Concets(Encapsulation,Abstraction,Class,Object,Inheritance,Early binding,Late Binding,Interface,Inheritance)


6)Creating Class File in Asp.Net 2.0 for Database Manipulations

This tutorial explains the programming with class file in Asp.Net 2.0 and explains the simplest way to do database manipulations through the class file. Class files are used to write business logic of the web applications and sometime used to manipulate database records also. The main advantage of a class file is code reusability and ease of code management


http://www.aspdotnetcodes.com/Creating_Class_File_Asp.Net.aspx


7) Creating javascript MENU's

http://dhtml.discoveryvip.com/


8) Good Interview Questions and Faq's in asp.net,sessions,C#.Net and sql server

http://www.akaas.net/dot-net-faqs/session-state.htm

9) ASP.Net Page Life Cycle.
Page_Init ,LoadViewState ,LoadPostData ,Page_Load ,RaisePostDataChangedEvent ,RaisePostBackEvent ,Page_PreRender ,SaveViewState ,Page_Render ,Page_UnLoad

ASP.Net Page Life Cycle


Happy Coding

Wednesday, October 24, 2007

Inserting Data Into Two Tables in sql server Stored Procedures

CREATE PROCEDURE procInsSamples
@CategoryID int,
@Title varchar(100),
@Description text,
@Link varchar(150),
@Whatever
AS
Begin
Set NoCount on
DECLARE @WhateverID INT
Insert Table1(Title,Description,Link,Whatever)
Values
(@title,@description,@link,@Whatever)

Select @WhateverID=@@Identity

Insert into Table2
(CategoryID,WhateverID)
Values
(@CategoryID,@WhateverID)
End

this Data will Get from http://aspnet101.com/aspnet101/tutorials.aspx?id=13

Friday, June 22, 2007

what is DBCC in Sql Server?

DBCC stands for database consistency checker. We use these commands to check the consistency of the databases, i.e., maintenance, validation task and status checks.
E.g. DBCC CHECKDB - Ensures that tables in the db and the indexes are correctly linked.
DBCC CHECKALLOC - To check that all pages in a db are correctly allocated.
DBCC CHECKFILEGROUP - Checks all tables file group for any damage.

What is DBCC in sql server?

DBCC stands for database consistency checker. We use these commands to check the consistency of the databases, i.e., maintenance, validation task and status checks.
E.g. DBCC CHECKDB - Ensures that tables in the db and the indexes are correctly linked.
DBCC CHECKALLOC - To check that all pages in a db are correctly allocated.
DBCC CHECKFILEGROUP - Checks all tables file group for any damage.

Wednesday, May 30, 2007

Interview Question at PUNE Based (CMM Level 3 Company)

This is telephonic Round From PUNE(CMM Level3 Company)

1) What is Abstact and interfae?
2) Access Modifiers in C#?
3) what is Purpose abt "Internal"?
4) Abstarct Methods accept the Access modifiers?
5) what is web.Config?
6) what is purpose abt Multiple web.config files for project and when that be used for?
7) what is AJAX?
8) what is XMLHttprequest()?
9) how i validate the DropDownlist with validation controles?
10)what is updatepanel and updateprogress in AJAX?
11)where u decalre conncetion string in webpages(ASP.Net) and in C#.Net?
12)what is trigger in AJAX?
13) who is invented the AJAX?
14) what is DTD?
15)what is DOM?
16)what is XSL? if any work u r doing on that ?
17)how can u call javascript in ASP.Net pages?
18)what is RegistredClientScriptBlock() in asp.net?
20)

Saturday, March 3, 2007

About a class access specifiers and method access specifiers ?

Class Access Modifier
---------------------
private
public
protected
internal
abstract
sealed

Method Access Modifier
----------------------
private
public
virtual
override
sealed

Thursday, February 15, 2007

Serialization and De-Serialization in C#.Net For Binary and Soap Formatters

About Serialization in .NET
.NET objects are serialized to a stream. Developers must use a .NET formatter class to control the serialization of the object to and from the stream. In addition to the serialized data, the serialization stream carries information about the object's type, including its assembly name, culture, and version.

Working with Formatters
A formatter is used to determine the serialization format for objects. All formatters expose an interface called the IFormatter interface. Two formatters inherit from the IFormatter interface and are provided as part of the .NET framework. These are the Binary formatter and the SOAP formatter.

The Binary Formatter
The Binary formatter provides binary encoding for compact serialization either for storage or for socket-based network streams. The BinaryFormatter class is generally not appropriate when data is meant to be passed through a firewall.

The SOAP Formatter
The SOAP formatter provides formatting that can be used to enable objects to be serialized using the SOAP protocol. The Soap Formatter class is primarily used for serialization through firewalls or among diverse systems.

Other Formatters
The .NET framework also includes the abstract FORMATTERS class that can be used as a base class for custom formatters. This class inherits from the IFormatter interface.

The Requirements for Serialization
Serialization is done so that the object can be recreated with its current state at a later point in time or at a different location. The following are required to Serialize an object:

The object that is to serialized itself.
A stream to contain the serialized object.
A Formatter used to serialize the object.
System.Runtime.Serialization is the namespace that contains the classes that are required to serialize an object.

To deserialize an object, the DeSerialize() method of the BinaryFormatter class is used.

Serializing an Object Using the Binary Formatter
I'll present a case study using ACME Corporation. Within the example, you should read the comments to clearly understand what is happening.

Ali Sufyan is an IT strategist for ACME Corporation. He needs a way to store the state of his objects to disk. The company uses C# to code its internal system applications. The application contains a class called PayRoll, which consists of the members like this:

MEMBER NAME
TYPE

uName
Property

uId Property
eName Property
eSal Property
CalcHRA() Method
CalcPF() Method
Deductions Property
NetSal Property


Sufyan wants to save the state of his object at any point in his program. You will help him mark the class as Serializable and persist the properties of the class to disk using the binary formatter.

using System;
namespace SufyanTestClass
{
// We are creating a simple class named SerialFor and to make
// that class serializable we added an attribute [Serializable].
// This attribute makes the class ready for Serialization

[Serializable]
public class SerialFor
{
/* [NonSerialized] attribute is used to make a method
* non-Serializable in a serializable envoironment. The
* condition is that Sufyan wants to make the property uname
* and uid non-serializable. While the remaining class remains
* serialized */

[NonSerialized]
public string uname;
[NonSerialized]
public int uid;
public string ename;
public int esal;
public int calcHRA(int a,int b)
{
return (a-b);
}

public int CalcPF(int a,int b)
{
return (b-a);
}

public int Deductions;
public int NetSal;
}
}
Build the project as a class library. To make your project a class library, you go to solution explorer, right-click the Project, select Properties and change the OutPut Type to class library. When you build the project a .dll file is created in the debug folder of your projects directory.

Now, open another project in which you will serialize this class. Add a reference to the DLL created by the previous code. You then can create the class with the following code:

using System;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;

namespace SerialsufyanTestClass
{
class Class1
{

[STAThread]
static void Main(string[] args)
{
SufyanTestClass.SerialFor obj= new
SufyanTestClass.SerialFor();
obj.Deductions=90;
obj.NetSal=1000;
Stream a= File.OpenWrite("C:\\abc.bin");
BinaryFormatter bf=new BinaryFormatter();
bf.Serialize(a,obj);
a.Close();
}
}
}
This listing will create a file named abc.bin. on the C: drive. We are serializing the whole class to the file as well as adding value to deductions and NetSal to the file. We will use this in the next example.

The above code serializes the class. Now, you will deserialize the same class:

using System;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;

namespace SerialsufyanTestClass
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
FileStream file=new FileStream( "C:\\abc.bin",
FileMode.Open);

BinaryFormatter bf=new BinaryFormatter();
SufyanTestClassForSerialization.SerialFor obj =
bf.Deserialize(file) as
SufyanTestClassForSerialization.SerialFor;
Console.WriteLine(obj.Deductions);
Console.WriteLine(obj.NetSal);
Console.WriteLine(obj.calcHRA());
Console.ReadLine();
}
}
}
This code will deserialize the class and calculates the HRA based on the values of Deductions and NetSal we have serialized to the file.

Using SOAP TO Serialize and Deserialize
Using a SOAP protocol to serialize and deserialize your code is more or less the same as above. A little change will be required. You have to add a reference to System.Runtime.Serialization.Formatters.Soap in your Application.

The following is a repeat the above serialize and deserialize code. However, this time it uses SOAP. The main benefit of SOAP Serialization is portability. You can share the serialization information with any other application on any platform.

using System;
using System.Runtime.Serialization.Formatters.Soap;
usingSystem.IO;
namespace SerialsufyanTestClass
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
SufyanTestClass.SerialFor obj=
newSufyanTestClass.SerialFor();
obj.Deductions=90;
obj.NetSal=1000;
Stream a=File.OpenWrite("C:\\abc.ex");

SoapFormatter bf=new SoapFormatter();
bf.Serialize(a,obj);
a.Close();
}
}
}
Deserializing Using SOAP
using System;
using System.Runtime.Serialization.Formatters.Soap;
using System.IO;

namespace {
classClass1
{static void Main(string[] args)
{
FileStream file=new FileStream( "C:\\abc.ex", FileMode.Open);
SoapFormatter bf=new SoapFormatter();
SufyanTestClassForSerialization.SerialFor obj =
bf.Deserialize(file) as
SufyanTestClassForSerialization.SerialFor;
Console.WriteLine(obj.Deductions);
Console.WriteLine(obj.NetSal);
Console.WriteLine(obj.calcHRA());
Console.ReadLine();
}
}
.NET Serialization & Object ReferencesIf a class that is to be serialized contains references to objects of other classes, and if those classes have been marked as serializable, then their objects are serialized too..NET serializes the objects state including the members of the base class or base classes. All members are serialized, including private or protected members. .NET knows their existence from the object's metadata and accesses these members using reflection.If the object has member variables that are serializable, then those members are serialized too. .NET serialization handles cyclic references, too. During the recursive serialization, even if one of the objects members (or one of the nested members) is not serializable, .NET throws a runtime exception. You must, however, ensure that all the base classes are serializable when you mark the class as serializable otherwise you might get unexpected results.Suppose you want to make a Windows form application serializable. You can create the DLL, but when you try to make the form application serializable through binary or soap formatters, an exception will be raised stating that the base class is not marked as serializable. The System.Windows.Forms base class is not Serializable, so you can't your forms application Serializable.

Interview Questions in ASP and VB at Accenture

hi friends.these all are interview Questions at Accenture...

1. Relation between vb and asp
2. How to register a CoM
3. How to call COM in asp
4. Project type u select to create a COM in VB
5. Any errors while calling Com object in asp
6. Explain about In-Process and Out-Process
7. How do debug Vb application
8. How do deploy Vb application
9. Difference between public variable and Public property
10.Friend function in VB
11.OOP's Concept
12.Objects in asp u have used
13.Methods of session object
14.methods of request object
15.use of request.querystring and request.form
16.How to call COM in asp
difference between server.createobject and object tag
17. Difference between inner join and outer join
18. types of outer joins and difference

All The Best

Tuesday, February 13, 2007

The "WAITFOR" KeyWord With in SqlServer

The "WAITFOR" Statement Suspends the Execution of a connection until either
- A specified time interval has passed
- A specified time day is Reached
EX:
use pubs
waitfor delay '00:00:05'
select * from sales

Disadvantages:
The Connection from the application remains suspended until the wait for complete.this is used at Stored Procedure

The "CHECK" KeyWord with in Sql Server

the "CHECK" Keyword in Sql Server:

/****************************************************************************/
Create Table datevalues(
orderid int primarykey
cid int
orderdate datetime null,
CHECK(DatePart(yy,orderdate)=2006)
ordermonth int
CHECK(ordermonth=5)
Deliverydate Datetime null
CHECK(DatePArt(mm,orderdate)=ordermonth)
)
/****************************************************************************/

Can We Use Truncate Command on a table which is Refernced by Foreign Key?

Can We Use Truncate Command on a table which is Refernced by Foreign Key?

NO,We Can't use Truncate Commmand on a table with Foreign key

Sql Server Good Example

if you have to give a flat hike to your EMPloyee using the Following Criteria
Salary b/w 2000 and 3000 then Hike is 200
Salary b/w 3000 and 4000 then Hike is 300
Salary b/w 4000 and 5000 then Hike is 400
IN EMPLOYEE Table

Then The Query is like that

/*************************************************************/
Update EMPLOYEE Set Salary =
Case when Salary between 2000 and 3000 then
Salary = Salary+200
Case when Salary between 3000 and 4000 then
Salary = Salary+300
Case when Salary between 3000 and 4000 then
Salary = Salary+300
End
/************************************************************/

Thursday, January 18, 2007

Abstract && interface with in C#.Net

Introduction
The choice of whether to use an interface or an abstract can sometimes be a difficult one. This article shows you the differences between these two and also tells you when and where to use them.


Interfaces
Interfaces, like classes, define a set of properties, methods, and events. But unlike classes, interfaces do not provide implementation. An interface represents a contract, and a class that implements an interface must implement every aspect of that interface exactly as it is defined.
You declare an interface by using the interface keyword


Example
interface IPerson
{
void Eat();

void Sleep();

int Weight
{
set;
get;
}
}

In order to use this interface, you must declare your class in the same way that you declare a class inheriting from any other object.


Example
public class Man:IPerson
{
int iWeight;

public Man()
{
}

public void Eat()
{
MessageBox.Show("Man:Eat");
}

public void Sleep()
{
MessageBox.Show("Man:Sleep");
}

public int Weight
{
set
{
iWeight = value;
}
get
{
return iWeight;
}
}

static void Main()
{
Man i = new Man();
i.Eat();
i.Sleep();
}

}


You get the following result when you run the above code.
Man:Eat
Man:Sleep

It is important to note here that an interface is very different from a base class. An interface is implemented, not extended.
1.A class can implement multiple interfaces.
2.An interface cannot contain data declarations but you can declare properties.
3.All method declarations in an interface are public.
4.There can be no implementation in an interface.
5.The class implementing the interface must provide implementation code.
6.An interface can be derived from another interface


Abstract Classes
An abstract class is a class that cannot be instantiated, but must be inherited from. An abstract class may be fully implemented, but is more usually partially implemented or not implemented at all, thereby encapsulating common functionality for inherited classes.

When you have a class that contains methods that have no implementation (i.e. abstract methods), the class is said to be abstract as well. An abstract method is simply a shell or place-marker for a method that will be defined later in a derived class. The intention of abstract methods is to force every derivation of the class to implement those methods. If a derived class does not implement an abstract method, then that class must also be declared as abstract.

You declare an interface by using the interface keyword
abstract public class Person
{
abstract public void Eat();

public void Sleep()
{
MessageBox.Show("Person:Sleep");
}

abstract public int Weight
{
set;
get;
}
}

You can inherit the abstract class just like any other class.
public class Man:Person
{
int iWeight;

public Man()
{
}
override public void Eat()
{
MessageBox.Show("Man:Eat");
}
override public int Weight
{
set
{
iWeight = value;
}
get
{
return iWeight;
}
}

static void Main()
{
Man i = new Man();
i.Eat();
i.Sleep();
}
}


You get the following result when you execute the above code.
Man:Eat
Person:Sleep

So why would you declare a class abstract? It’s actually a very powerful class hierarchy design tool since you can provide the structure for something that is not very specific —just like our Person class. You will never create an Person object; but you will create Man and Woman objects. The other advantage is that you are moving the code to where it actually belongs. This helps you locate program logic problems.

A class that is derived from an abstract class may still implement interfaces.

Abstract classes are useful when creating components because they allow you specify an invariant level of functionality in some methods, but leave the implementation of other methods until a specific implementation of that class is needed. If additional functionality is needed in derived classes, it can be added to the base class without breaking code.

In the above example, an abstract class is declared with one implemented method, one unimplemented method and one unimplemented property. A class inheriting from this class would have to implement the Eat method and Weight property

When implementing an abstract class, you must implement each abstract method in that class, and each implemented method must receive the same number and type of arguments, and have the same return value, as the method specified in the abstract class.


Recommendations on using Abstract Classes and Interfaces
1. If you anticipate creating multiple versions of your component, create an abstract class. Abstract classes provide a simple and easy way to version your components. By updating the base class, all inheriting classes are automatically updated with the change. Interfaces, on the other hand, cannot be changed once created. If a new version of an interface is required, you must create a whole new interface.
2. If the functionality you are creating will be useful across a wide range of disparate objects, use an interface. Abstract classes should be used primarily for objects that are closely related, whereas interfaces are best suited for providing common functionality to unrelated classes.
3. If you are designing small, concise bits of functionality, use interfaces. If you are designing large functional units, use an abstract class.
4. If you want to provide common, implemented functionality among all implementations of your component, use an abstract class. Abstract classes allow you to partially implement your class, whereas interfaces contain no implementation for any members.


Abstract class vs. interfaces
Abstract class Interface
May or may not have abstract methods. Can only have abstract methods (Implicitly abstract) but abstract keyword is not allowed.
Methods can have access modifiers. No access modifier is allowed, implicitly public.
Can have fields. Not intended to define fields.
Can be instantiated via sub-class. Can be instantiated via implementing class.
Can extend a Single class, implement one or more interfaces. Cannot extend a class, Can extend single or multiple interfaces.
Abstract classes form part of the inheritance scheme Interfaces do not. We can use the same interface in two projects that are not related in terms of inheritance. For example an interface IWheel can be implemented in a Car project and also a Bicycle project.
Can have constructor. Can't have constructor.
A class, by comparison, can only extend ("implementation inheritance") one other class Interfaces provide a form of multiple inheritance ("interface inheritance"), because you can implement multiple interfaces.
An abstract class can have static methods, protected parts, and a partial implementation. Interfaces are limited to public methods and constants with no implementation allowed.


if you want some more Stuff on this topic then Click here
Click Here


Labels: , , ,

How can i break line in message box?

this is the way to break the message:

MessageBox.Show (“This Text is displayed in First Line” & vbcrlf &
“This Text is displayed in Second Line”)

Tuesday, January 16, 2007

.Net Framework

Introduction

In this article we are going to look at Microsoft .NET Framework. This is the newly established software development environment which helps developers to develop applications quickly and gives optimum, efficient, scalable, performance oriented applications in different languages like Visual Basic .NET, C#, ASP .NET, and Jscript .NET etc…

Overview of the .NET Framework

The .NET Framework is a new computing platform that simplifies application development in the highly distributed environment of the Internet.

Services

NET Framework provides the following services:
· Tools for developing software applications,
· run-time environments for software application to execute,
· server infrastructure,
· value added intelligent software which helps developers to do less coding and work efficiently,
The .Net Framework will enable developers to develop applications for various devices and platforms like windows application web applications windows services and web services.

Objectives

The .NET Framework is designed to fulfill the following objectives:
· A consistent object-oriented programming environment, where object code can be stored and executed locally, executed locally but Internet-distributed, or executed remotely.
· A code-execution environment that minimizes software deployment and versioning conflicts.
· A code-execution environment that guarantees safe execution of code, including code created by an unknown or semi-trusted third party.
· A code-execution environment that eliminates the performance problems of scripted or interpreted environments.
· Developers can experience consistency across widely varying types of applications, such as Windows-based applications and Web-based applications.
· Build all communication on industry standards to ensure that code based on the .NET Framework can integrate with any other code.

Understanding the .NET Framework Architecture

The .NET Framework has two components: the .NET Framework class library and the common language runtime.
The .NET Framework class library facilitates types (CTS) that are common to all

.NET languages.

The common language runtime consists of (class loader) that load the IL code of a program into the runtime, which compiles the IL code into native code, and executes and manage the code to enforce security and type safety, and provide thread support.



.NET Framework Architecture has languages at the top such as VB .NET C#, VJ#, VC++ .NET; developers can develop (using any of above languages) applications such as Windows Forms, Web Form, Windows Services and XML Web Services. Bottom two layers consist of .NET Framework class library and Common Language Runtime. This we are going to understand using this article.

Understanding the Roll of .NET Framework.

The .NET Framework has two main components: the common language runtime (CLR) and the .NET Framework class library. The common language runtime is the foundation of the .NET Framework. CLR act as an agent that manages code at execution time, providing core services such as memory management, thread management, and remoting, while also enforcing strict type safety and facilitates with code accuracy that ensure security and robustness. The concept of code management is a fundamental principle of the CLR. Code that targets the CLR is known as managed code, while code that does not target the CLR is known as unmanaged code.

The class library, is a integral component of the .NET Framework, consists of object-oriented collection of reusable classes (types) that we can use to develop applications ranging from traditional command-line or any graphical user interface (GUI) applications such as Windows Forms, ASP. NET Web Forms and Windows Services the newly invented XML Web services.

The European Computer Manufacturers Association (ECMA) standard has defines the Common Language Specification (CLS); this enforces that software development languages should be interoperable between them. The code written in a CLS should be compliant with the code written in another CLS-compliant language. Because the code supported by CLS-compliant language should be compiled into an intermediate language (IL) code. The CLR engine executes the IL code. This ensures interoperability between CLS-compliant languages. Microsoft .NET Framework supports Languages like Microsoft Visual Basic .NET, Microsoft Visual C#, Microsoft Visual C++ .NET, and Microsoft Visual J# .NET.

The language compilers generate an Intermediate Language code, called Microsoft Intermediate Language (MSIL), which makes programs written in the .NET languages interoperable across languages.

The ECMA standard, Common Language Infrastructure (CLI), defines the specifications for the infrastructure that the IL code needs for execution. The CLI provides a common type system (CTS) and services such as type safety, managed code execution and side by side execution.



Figure 1. ECMA Standards under Microsoft .NET Framework.
The .NET Framework provides the infrastructure and services. The CLI specifications. These include:
· Common language runtime.
o The CLR includes the CLI,
o The CLR also provides the execution environment for .NET Applications.
· Common type system.
o Provides the data types, values, object types. This helps developers to develop applications in different languages.Where .NET languages share CTS mean all the types used in applications shares the same types defined under CLI.
· Type safety.
o .NET Framework performs operations on the values or objects for which .NET Framework requires each value or object has a type and which reference to the value or object type.
· Managed code execution.
o .NET Framework manages the state of the object while executing the .NET Applications.
o .NET Framework automatically allocates memory and provides garbage collation mechanism to de-allocate memory.
· Side-by-side execution.
o .NET Framework allows different version of the same application to run on the same machine by using assemblies of different versions. Assemblies consist of IL Code and Metadata. Where metadata determines the application dependencies. By this .NET Framework Runtime executes multiple version of assembly and solves the major problem of legacy development environment. That is the “DLL HELL”.

.NET Assembly



Figure 2 Side-by-side Execution.


Understanding .NET Framework CLR

The common language runtime facilitates the followings:
· Run-time environment
o CLR Compiles application into the runtime, compile the IL code into native code, execute the code
· Run-time services.
o Memory management,
o Type safety,
o Enforces Security,
o Exception Management.
o Thread support
o Debugging support



Understanding Architecture of .NET Framework CLR




· Class loader, which loads classes into CLR.
· MSIL to native code compiles, this converts MSIL code into native code.
· Code manager, this manages the code during execution.
· Memory allocation and Garbage collector, this performs automatic memory management.
· Security engine, this enforces security restrictions as code level security folder level and machine level security using tools provided by Microsoft .NET and using .NET Framework setting under control panel.
· Type checker, which enforces strict type checking.
· Thread support, which provides multithreading support to applications.
· Exception manager, which provides a mechanism to handle the run-time exceptions handling.
· Debug engine, which allows developer to debug different types of applications.
· COM marshaler, which allows .NET applications to exchange data with COM applications.
· Base class library support, which provides the classes (types) that the applications need at run time.

Features of the Common Language Runtime

The CLR has the following Fractures
· Manages memory,
o Allocation of Memory
o De-Allocation of Memory (garbage collation)
· Thread execution support,
· Code execution,
· Code safety verification,
· Compilation.
o MSIL to Native Code.
· Code Security based on Trust (granted permission to execute code. Code level, Folder level, Machine level) These features are intrinsic to the managed code that runs on the common language runtime.

Understanding CLR

To execute the program and gain all the benefits of managed execution environment we write code in a language which is supported by CLS that is .NET Framework. The language compiler compiles the source code into the MSIL code which consists of CPU- independent code and instructions which is platform independent. MSIL consists of the followings:
· Instructions that enables to perform arithmetic and logical operations
· Access memory directly.
· Control the flow of execution,
· Handles exceptions,
MSIL code can be compiling into CPU specific instructions before executing, for which the CLR requires information about the code which is nothing but metadata. Metadata describes the code and defines the types that the code contains as well referenced to other types which the code uses at run time.
An assembly consists of portable executable file. At the time of executing PE file the class loader loads the MSIL code and the metadata form the portable executable file into the run time memory.
Before the execution of PE file it passes the code to the native code compiler for compilation, IL to native code compilation is done by JIT compiler. For different CPU architecture and compilers for the IL code in to the native instructions.

Futures of CLR
· Managed multithreading support and monitor the threads. Application domain contains one or more threads to execute.
· Manages interoperability with unmanaged code, and COM marshaling
· A structured exception handling mechanism,
· The infrastructure and managed execution process, memory management and garbage collection.

Architecture of CLR



· Base class library support supports al the base classes used for .net languages to support basic functionality
· COM Marshaler supports Marshaling of data between COM objects.
· Exception management supports handling Errors at runtime using try catch finally blocks.
· Security engine enforces security rules at runtime.
· Type checker checks for Type safe checks at runtime.
· Debug engine supports debugging at runtime.
· Code manger manages the Managed code at runtime.
· IL to native compiler compiles the MSIL code to the Native code which is machine independent
· Garbage collector supports the Memory management and supports Clearing unused memory at runtime.
· Class loader lodes the classes at runtime


Understanding JIT compiler

JIT compiler compiles is the integral part of CLR. the MSIL code to Native code and executes the batch of code Just in time which will be cached and next time when the code gets executed from cache in stud of compiling again.



JIT Execution process.

CLR class loader lodes MSIL code and metadata are loaded into memory; the code manager calls the entry point method which is WinMain or DLLMain method. The JIT compiler compiles the method to before its execution of the entry point method. The code manager places the objects in memory and controls the execution of the code. The garbage collector performs periodic checks on the managed heap to identify the objects which is not in use for the application.
At the time of program execution the type checker ensures that all objects and values, and the references of objects and values has its valid type. The type checker also makes sure that only valid operations are performed on the code other wise the exception will be thrown. The code is controlled by CLR at run time. CLR enforces security in following manner.
· To control and access the system recourses like hard disk
· To control and access the network connections
· To control and access the other hard ware resources.

Managed code Execution

Managed code execution is known as the process executed by the CLR which is as follows:
· CLR loads the MSIL & refers metadata,
· CLR executes the Native code,
· CLR provides automatic memory management.
· Managed execution also performs JIT compilations,
· Ensuring type safety,
· Enforcing security,
· Handling exceptions.

Managed Execution Process
· Managed code is self-explanatory code which gives information to CLR for multiple runtime services in .NET Framework.
· This information is stored in MSIL code in the form of metadata inside the PE file. Mata data information will describe the types that the code contains.
· Managed data is allocated and released from memory automatically by garbage collection. Managed data can be accessible form managed code but managed code can be accessible from managed and unmanaged data.

Memory Management

Automatic memory management means no need to write code to allocate memory when objects are created or to release memory when objects are not required the application.
The process of automatic memory management involves the following tasks:

Ø Allocating memory
· When a process is initialized, the runtime reserves a contiguous address space without allocating any storage space for it.
· This reserved address space is called a managed heap. The managed heap keeps a pointer at the location where the next object will be located.
· When an application uses the new operator to create an object, the new operator checks whether the memory required by the object is available on the heap.
· When the next object is created, the garbage collector allocates memory to the object on the managed heap.
· Allocating memory to the objects in a managed heap takes less time than allocating unmanaged memory.
· In unmanaged memory, the pointers to memory are maintained in linked-list data structures. Therefore, allocating memory requires navigating through the linked list, finding a large memory block to accommodate the
· You can access objects in managed memory faster than objects in unmanaged memory because in managed memory allocation, objects are created contiguously in the managed address space.

Ø Releasing Memory
· The garbage collector periodically releases memory from the objects that are no longer required by the application.
· Every application has a set of roots. Roots point to the storage location on the managed heap. Each root either refers to an object on the managed heap or is set to null.
· An application's roots consist of global and static object pointers, local variables, and reference object parameters on a thread stack.
· The JIT compiler and the run-time maintain the list of the application roots. The garbage collector uses this list to create a graph of objects on the managed heap that are reachable from the root list.
· When the garbage collector starts running, it considers all the objects on the managed heap as garbage.
· The garbage collector navigates through the application root list, it identifies the objects that have corresponding references in the application root list and marks them as reachable.
· The garbage collector also considers such objects as reachable objects.
· The garbage collector considers all unreachable objects on the managed heap as garbage.
· The garbage collector performs a collection process to free the memory occupied by the garbage objects.
· The garbage collector performs the memory copy function to compress the objects in the managed heap.
· The garbage collector updates the pointers in the application root list so that the application roots correctly point to the objects to which they were pointing earlier.
· The garbage collector uses a highly optimized mechanism to perform garbage collection. It divides the objects on the managed heap into three generations: 0, 1, and 2. Generation 0 contains recently created objects.
· The garbage collector first collects the unreachable objects in generation 0. Next, the garbage collector compacts memory and promotes the reachable objects to generation 1.
· The objects that survive the collection process are promoted to higher generations.
· The garbage collector searches for unreachable objects in generations 1 and 2 only when the memory released by the collection process of generation 0 objects is insufficient to create the new object.
· The garbage collector manages memory for all managed objects created by the application.
· The garbage collection can explicitly release these system resources by providing the cleanup code in the Dispose method of the object.
· We need to explicitly call the Dispose method after you finish working with the object.

Ø Implementing Finalizers
· The finalization process allows an object to perform cleanup tasks automatically before garbage collection starts.
· The Finalize method ensures that even if the client does not call the Dispose method explicitly, the resources used by the object are released from memory when the object is garbage collected.
· After the garbage collector identifies the object as garbage during garbage collection, it calls the Finalize method on the object before releasing memory.
· Finalizers are the methods that contain the cleanup code that is executed before the object is garbage collected. The process of executing cleanup code is called finalization. The Dispose and Finalize methods are called finalizers.
· The Dispose method of an object should release all its resources in addition to the resources owned by its parent object by calling the Dispose method of the ?parent object.
· We can execute the Dispose method in two ways.
o The user of the class can call the Dispose method on the object that is being disposed, or
o The Finalize method can call the Dispose method during the finalization process.
.NET Framework Tools

Assembly Linker
Al.exe Tool
· tool can create an assembly or resource file with the manifest in a separate file out of modules.
Syntax: al [source] [options]
· This tool allows us to create multi-file assembly outside .NET. A multi-file assembly is useful to combine modules developed under different .NET languages into a single application.
IL Assembler
Ilasm.exe Tool
· When we compile managed code, the code is converted into MSIL code; this is CPU independent language which is converted to native code.
· We can use Ilasm tool to generate a portable executable (PE) file from the MSIL code. The resulting executable file is performance optimized, where the Ilasm tool does not create intermediate object file Syntex:
Ilasm [source] filename [options]
· We can specify multiple source files to produce a single PE file.
IL Disassembler
Ildasm.exe Tool
· Ildasm tool is used to view PE file contains that is nothing but the MSIL code as a parameter and creates the text file that consists of managed code.
Code Access Security Policy Tool
Caspol.exe Tool
· Caspool is nothing but Code Access Security Policy tool, which allows us to grant and modify permissions granted to code groups at the user-policy, machine-policy, and enterprise-policy levels. Etc…
Syntex: caspol [options]

.NET Framework Configuration Tool
Mscorcfg.msc
· With this tool we can manage and configure assemblies in to the global assembly cache. And also manage the code access security along with remoting services.
· This tool also creates code group policies at user level- policies, machine level-policies, and enterprise level policies to assign and remove the permissions on assemblies within .NET Framework.

Microsoft Certified Exam




HI Pals...This is MCP/MCAD Exam MOdel list.Prepare well..All the Best