Wednesday, December 20, 2006

System.Collections.Generic

Generic is a new feature introduced in C#. It is nothing but a type-safe collection. Generic collection can store only items that are compatible with argument type specified in declaration. Moreover generic collection works in similar way like non-generic collection, only the difference is to mixed types are not allowed. Non-generic collections are useful in case if you want to mix-up unrelated data types. List, Dictionary are example of C# generics.

Example:

using System;
using System.Collections.Generic;

class GenericDemo
{
public static void Main()
{
List lstInteger =new List();

//Add elements to generic integer list
//Correct entry as per generic
lstInteger.Add(1);
lstInteger.Add(2);
lstInteger.Add(3);
lstInteger.Add(4);
lstInteger.Add(5);


//Code exception due to following wrong entry
lstInteger.Add(‘Kuldeep’);
}
}


Because of type-safety principle, in above example it will throw error at last lstInteger.Add(‘Kuldeep’) statement. Current declaration for generic is an integer and at last statement you'r trying to insert is a string type. So it will raise exception.

Tuesday, December 19, 2006

The Mutex (C# - Threading)

Mutex is used to set exclusive access on shared resources in multi-thread programs. This means only one thread can access shared object at a time. A mutex is a perfect synchronization mechanism in C# threading.

Consider a example of when two threads accessing same system resources like files, system registry, Environment variables, etc. And you want to put exclusive access in multithreaded environment on shared resources then this can be achieved using mutex.

System.Thread.Mutex Class:

Above class supports Mutex.

To acquire Mutex call WaitOne()

To release Mutex call ReleaseMutex()

Example:

using System.Threading;

Mutex objMutex = new Mutex();

//Some code goes here

objMutex.WaitOne(); //Acquire

//Code to get exclusive access

//.....

objMutex.ReleaseMutex(); //Release

Mutex Code Snippet:

using System.Threading;

class FileAccess

{

public static Mutex mtx = new Mutex(); //Mutex variable

//Method to read/write in File

}

class FirstThread

{

public Thread t1;

//Uses above class method to R/W file

FirstThread()

{

t1= new Thread(this.CallFileWrite);

t1.Start();

}

void CallFileWrite()

{

FileAccess.mtx.WaitOne();

Console.WriteLine(“t1: In Mutex ”);

//File writing code ......

Console.WriteLine(“t1: Out Mutex ”);

FileAccess.mtx.ReleaseMutex();

}

}

}

class SecondThread

{

public Thread t2;

//Uses above class method to R/W file

SecondThread()

{

t2= New Thread(this.CallFileWrite);

t2.Start();

}

void CallFileWrite()

{

FileAccess.mtx.WaitOne();

Console.WriteLine(“t2: In Mutex ”);

//File writing code ...... for same file in t1 thread

Console.WriteLine(“t2: Out Mutex ”);

FileAccess.mtx.ReleaseMutex();

}

}

class MutexExample

{

void main()

{

FirstThread mFt1 = new FirstThread();

SecondThread mSt2 = new SecondThread();

MFt1.t1.Join();

MSt2.t2.Join();

}

}

Exception Handling in C#

Exception class is used to handle errors occurred during execution of code. Following are public members of exception class:

HelpLink : Used to set help link for exception.

InnerException: Gets the exception instance that caused the current exception.

Message: Exception description.

Source: Object that caused exception

StackTrace: Call stack for occurred exception.

TargetSite: Method that throws the exception.

Simple exception handling code block:

try

{

// Code statements.

}

catch(Type x)

{

// handling of the exception

}

finally

{

//cleanup code (if any)

}

Note: Catch block is optional in C#. And Finally block always execute.

Multiple Catch Blocks: (All good Programs must be able to uniformly handle errors that occur during code execution.)

try

{

//Your code goes here

}

catch(DivideByZeroException dz)

{

//Divide by zero exceptions will be handled here.

}

catch(OutOfMemoryException oe)

{

//Out of memory exceptions will be handled here.

}

catch(NullReferenceException ee)

{

//Null refernce exceptions will be handled here.

}

catch(Exception ex)

{

//Unknown exceptions from above 3 types will be handled here.

}

finally

{

//Always executes at the end.

}

Some Other Exception types:

IndexOutOfRangeException (Occures in looping when Index is out of range)

InvalidOperationException (Thrown by methods when in an invalid state.)

ArgumentNullException (Thrown by methods that do not allow an argument to be null.)

ComException (COM components)

InvalidCastException

ArithmeticException

SqlException (For DB related exceptions)

ApplicationException Class:

If you are designing an application that needs to create its own exceptions, derive from the ApplicationException class. ApplicationException extends Exception class.

To know more about structured and ApplicatioException handling goto http://www.devcity.net/Articles/284/1/article.aspx (This is supported by Microsoft)

Best practices to handling exceptions:

URL:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconbestpracticesforhandlingexceptions.asp

Sunday, October 15, 2006

Building Easy Navigation Using the ASP.NET 2.0 MultiView and Wizard Controls

ASP.NET 2.0 introduced over 50 new controls including the MultiView and Wizard controls. In this article Kuldeep Deokule will show you how to use the MultiView and Wizard controls to build an easy to navigate web application. He will explain the use of the MultiView control using an online survey application and Wizard control using a User Registration application. He will also show how the use of these two controls greatly reduces the amount of code required to be written, as compared to previous versions of ASP.NET. More...

Monday, October 02, 2006

The Development Tools for .NET Framework 3.0 : " Orcas "

The Development Tools for .NET Framework 3.0 (SEPTEMBER CTP) provides developers with support for building .NET Framework 3.0 applications using the final released version of Visual Studio 2005. These tools are provided as an early preview of technology being considered for the Orcas release of Visual Studio.

Visit URL for download Orcas:

http://www.microsoft.com/downloads/details.aspx?FamilyID=cc77abfa-a000-48d0-98c9-4ae083033d09&DisplayLang=en

Thursday, September 21, 2006

Why SOA?

1. Service oriented
2. Agile development
3. Removes complexity
4. Supplies common programming interface and interoperability protocol
5. Easy up-gradation
6. Lead towards automated business automation
7. Based on XML
8. Web service platform
9. Reusability
10. Loosely coupled
11. Ease in integration process.
12. Able to leverage existing application and infrastructure
13. Less maintenance cost involved.
14. Reduces hardware cost.
15. Leverage existing development skills
16. Faster application development.
17. Eliminate redundant systems and architecture.
18. Reduce project risk
19. Secured.
20. Flexibility

Sunday, September 03, 2006

Brief on SOA:

The buzzword SOA means Service Oriented Architecture. SOA is loosely coupled in nature. It based on SOAP (Simple Object Access Protocol). As per World Wide Web Consortium (W3C) SOA is 'A set of components which can be invoked, and whose interface descriptions can be published and discovered'.

By using SOA architecture it is possible to develop abstract, reusable, relevant, standard, consumable and standardized solutions.

SOA plays major role in enterprise level integration.

Saturday, September 02, 2006

Article: Data Binding and Static Items in List Controls

Abstract:

In this article Kuldeep Deokule shows you how to add static items while implementing data binding on list controls.

Introduction:

ListControl is the abstract class for all list type controls (System.Web.UI.WebControls.ListControl). These list type controls are CheckboxList, DropdownList, Listbox, RadiobuttonList. The properties of the ListControl class allow you to specify the source of the data to populate the list controls. Use the DataSource property to specify the data source to bind to the list controls. Consider the scenario, you’ve a DropdownList control on a web form that is binded to datasource control like SqlDataSource or ObjectDataSource. DropdownList will populate with list of newsletters.

Now, as a good developer you’ve added functionality to select multiple items in DropdownList control by holding control key down. But suppose some user want to receive all newsletters. If you say to user, select all newsletters one by one by holding control key down. This will become very tedious process for any user. User will hate to do this task. So now you want to add one static item “Send All Newsletters” as a top item in the DropdownList. So if user wants to receive all newsletters, user will just select one item. One more design point is on a web page Newsletters DropdownList field is an optional selection for user. So it is impossible to create a DropdownList that doesn’t have a selected item. At least one item in DropdownList control is always selected. So you decided to add one more item in DropdownList control as “Select”. This will be top and default item in DropdownList control.

But due to data binding limitation, “Select” and “Send All Newsletters” list items will be destroyed when you run the web page. Only fetched newsletters from database will be available in DropdownList control. So how to solve this problem?

Solution:
Data source controls make developers life easier but in some case they cannot go beyond bounds specified. It is a limitation of data source controls that they destroy static items created earlier. Most websites need static items in list type controls.

To work out with this problem some developers like to add static items to database directly. But it is not a good idea. These items will unnecessarily reflect in every report related to newsletters table.

Some experienced developers put UNION query in SelectCommand of the data source controls like shown below:

SELECT ‘(Send All Newsletters)’ as AllNewsLetters
UNION
SELECT DISTINCT Newsletters FROM Newsletters

Again above UNION query is not a good idea. By doing this you are adding presentation logic details to data layer, which is not a good programming practice.

It is a weakness of data binding model that you cannot add static items. But static items are required in many cases in list type controls. So what is a good solution to solve above problem? Just take a look at following steps to solve the problem:

1. Add DropdownList control to web form.
2. Do not set any data source control to it through property window or using smart tag.
3. Add Page_Load event in code behind file as show below:

Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
'Set up the data binding.
NewsletterList.DataSource = SqlDataSource1
NewsletterList.DataTextField = "newsletter"
NewsletterList.DataValueField = "id"
NewsletterList.DataBind()


'Add following items and select the first item by default.
NewsletterList.Items.Insert(0, "Select")
NewsletterList.Items.Insert(1, "Send All Newsletters")
NewsletterList.SelectedIndex=0
End If
End Sub

Now browse the web page. All static and dynamic items are present in DropdownList control. Insert method with position value add items in DropdownList control at appropriate locations. Code line NewsletterList.SelectedIndex=0 cause to select top item as a default item for DropdownList control. Instead of SqlDataSource control you can also use ObjectDataSource control for data binding purpose. Code will remain same for both data source controls only DataSource attribute will change to respective control name.

AppendDataBoundItems Property in ASP.NET 2.0:

ASP.NET 2.0 exposes AppendDataBoundItems property for all list type controls. This property make this task little easier. If AppendDataBoundItems property is set to true for DropdownList control. Then added static items are not destroyed at the time of page load.
Just take look at following code:

Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
'Set up the data binding.

NewsletterList.Items.Add("Select")
NewsletterList.Items.Add("Send All Newsletters")
NewsletterList.AppendDataBoundItems = True
NewsletterList.DataSource = SqlDataSource1
NewsletterList.DataTextField = "newsletter"
NewsletterList.DataValueField = "id"
NewsletterList.DataBind()

NewsletterList.SelectedIndex=0
End If
End Sub



If you set AppendDataBoundItems property to False then all static items will be destroyed. Value of AppendDataBoundItems is stored in view state.
So AppendDataBoundItems will do all magic for us. AppendDataBoundItems is only available in .NET framework 2.0. So for ASP.NET 1.x this solution will not work.

Conclusion:
In this way we can go beyond the limits of data source controls. Above solutions will help you to add static items to data bound list type controls.

Wednesday, July 12, 2006

Hello Everybody,

New blog is started on DNS. Please visit following link:

http://dotnetslackers.com/community/blogs/kuldeepdeokule/

Thursday, June 15, 2006

What is in .NET 3.0?

Following things are present in .NET 3.0:

1. .NET Framework 2.0
Common Language Runtime (CLR)
Base Class Library
ADO.NET 2.0, ASP.NET 2.0, Windows Forms 2.0
VB 8.0 and C# 2.0
2. WinFX
Windows Communication Foundation (WCF)
Windows Presentation Foundation (WPF)
Windows Workflow Foundation (WF)
3. InfoCard
Renamed to Windows CardSpace (WCS)

WinFX is useful to build SOA(Sevice Oriented Architecture), n-tier, etc...
IMP: .NET 2.0 Framework and compilers are unchanged, so your existing code will continue to run as it exists today in .NET 3.0

Tuesday, June 13, 2006

.NET Framework 3.0

.NET Framework 3.0!

.NET Framework 3.0 now is a name for WinFX. To know more click here.

Saturday, June 10, 2006

Building a 3-tier Architecture Using the ObjectDataSource in ASP.NET 2.0


Abstract


ASP.NET 2.0 has introduced a series of new data source controls that simplify the life of developers. Developers can now connect to a database and perform CRUD operations with a minimal amount of code or in some cases no code at all. To enable developers to insert business logic into their applications the new ObjectDataSource control is provided in ASP.NET 2.0. In this article Kuldeep Deokule will use an example Employee listing application to show how to incorporate business logic in a 3 tier application using the new ObjectDataSource control. more...

Tuesday, June 06, 2006

What is Obfuscation?

Obfuscation is used to lock your .NET application binary. Here locking is not done using any encryption algorithm. Microsoft .NET platform offers greater level of flexibility to develop applications. But reverse engineering of the source code is also easily possible.
Microsoft .NET platform uses MSIL (Microsoft Intermediate Language) to produce executable code. This MSIL is higher level in nature than machine code.

One can use a de-compiler program to reverse engineer .NET applications. That means your source code is not safe. Here obfuscation technique comes in focus. To stop reverse engineering of .NET applications obfuscation can be used. It is not a encryption technique. Obfuscation convert meaningful terms in source code to non-meaningful. For example your source code contains variables named intEmployeeId, intNoofChildern, etc then these variable names converted to a, b, etc.

So due to obfuscation implementation source code becomes difficult to understand. Obfuscation is not a 100% proof technique to stop reverse engineering on your source code. But it makes your .NET application source code more secure.

Obfuscation technique even renames the names of methods, properties, functions, procedures, and events to meaning-less names. At the same time obfuscation take care of application’s performance. It is not affected due to obfuscation implementation. It keep your application intact.

Microsoft Visual Studio provides Dotfuscator tool to perform obfuscation since it 2003 release.

Saturday, May 13, 2006

Steps to Configure SQL Cache Invalidation

Note: SQL Cache Invalidation feature works with only SQL Server 7/2000/2005. Not works with databases like Oracle, Ms- Access.

To configure SQL cache invalidation two steps are required, first configure SQL server to cache invalidation and second add configuration information in “caching” section under “system.web” in web.config file.

Following are the important steps to configure SQL server:

I’ve used database named “Payroll”. In payroll, I am going to set SQL cache validation on “Employee” table which contains detailed information of working employees.

1. Open Visual Studio .NET 2005 command prompt. (By navigating to Microsoft Visual Studio 2005 -> Visual Studio Tools -> Visual Studio .NET 2005 Command Prompt)
2. Use aspnet_regsql tool to enable SQL cache invalidation. The aspnet_regsql tool is present in your Windows\Microsoft.NET\Framework\[version] folder. Use command prompt to navigate for this folder.
3. To enable SQL cache invalidation on payroll table in SQL Server issue following command.

aspnet_regsql -E -d Payroll –ed

Press enter to execute the command.

Following is the information about options used with aspnet_regsql command:
-E: Used to enable integrated security when connecting to your database server.
-d: Used to select the Payroll database.
-ed: Used to enable the database for SQL Cache Invalidation.
payroll: It is the name of database.

After successful execution of an above command AspNet_SqlCacheTablesForChangeNotification, new table is added to the payroll database. This table contains a list of all of the database tables that are enabled for SQL cache invalidation. Some new stored procedures are also added to the database.


4. Now select a table in payroll database for SQL cache invalidation. Let’s select “Employee” table.

aspnet_regsql -E -d Payroll -t Employee –et

Following is the information about option used in above commands:
-t: Used to select a database table. In my case it is Employee table.
-et: Used to enable a database table for SQL cache invalidation.

To enable cache invalidation for multiple tables re-execute this command for each database table.
This command adds trigger to database table. Trigger fires whenever changes are occurred in that table.

By doing above steps configuration at SQL server is complete here. But second part is still remaining that is adding some entries in web.config file without this caching won’t work even if you configured it for SQL Server.

File Name: web.config

<configuration>

<connectionStrings>

<add name="PayrollConnection"

connectionString="Server=localhost;Database=Payroll" />

</connectionStrings>

<system.web>

<caching>

<sqlCacheDependency enabled="true">

<databases>

<add name="Payroll"

connectionStringName="PayrollConnection"

pollTime="50000" />

</databases>

</sqlCacheDependency>

</caching>

</system.web>

</configuration>

Friday, April 28, 2006

Difference between SqlDataSource and ObjectDataSource

Following is a difference between SqlDataSource and ObjectDataSource:
1. SqlDataSource is two-tier in nature where as ObjectDataSource supports three-tier architecture.
2. SqlDataSource requires very small amount of coding to connect with database. For ObjectDataSource more coding is required to build data access class.
3. SqlDataSource not support full encapsulation. ObjectDataSource supports full encapsulation.
4. SqlDataSource requires complete connection string to connect with database. ObjectDataSource exposes TypeName attribute that is a name of middle layer class may used to perform database related operations. Data access class must be placed in App_Code directory.
5. Caching is same for both controls but ObjectDataSource control fires NotSupported exception if return type of SelectMethod is other than DataSet.

Thursday, March 30, 2006

How to: Get list of table names from MS Access Database in ASP.NET 2.0

To get a list of table names from database use following code:

Dim sConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\sample.mdb"
Dim olecon As New OleDbConnection(sConn)
olecon.Open()
Dim tblrestrictions As String() = New String() {Nothing, Nothing, Nothing, "TABLE"}
Dim dt As DataTable = olecon.GetSchema("tables", tblrestrictions)
olecon.Close()
GridView1.DataSource = dt
GridView1.DataBind()

Restrictions are a string array in the following format:
{TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE}.

Using ADOX and Msysobjects works fine with windows applications but may problematic for web apps[permission related problems]. If you use Msysobjects directly in query, following error will be displayed:

Record(s) cannot be read; no read permission on 'MSysObjects'

So it's better to use GetSchema with restriction.

How To - ExecuteScalar ()

When To Use:

Executes the query, and returns the first column of the first row in the resultset returned by the query. Extra columns or rows are ignored.

ExecuteScalar is a fast way to fetch one value.


Results:

If ExecuteScalar return 0 (zero) means no similar record found in database (According to condition is defined in WHERE clause).


Code Snippets:

Snippet 1:

Scenario: Avoid entry of duplicate user names by using ExecuteScalar method.

DBConnection.Open()
SQLString = "SELECT Count(*) FROM tblLogin " & _
WHERE username = '" & txtUserName.Text & "'"
DBCommand = New OleDbCommand(SQLString, DBConnection)
If DBCommand.ExecuteScalar() <> 0 Then
lblError.Text = "Sorry. User Name Already Present."
End If
DBConnection.Close()


Snippet 2:

Scenario: Check whether User Name and Password is present in database by using ExecuteScalar method.

DBConnection.Open()
SQLString = "SELECT Count(*) FROM tblLogin " & _
WHERE username = '" & txtUserName.Text & "' AND Password='" & txtPassword.Text & "'"
DBCommand = New OleDbCommand(SQLString, DBConnection)
If DBCommand.ExecuteScalar() <> 0 Then
'IF condition satisfied means User Name and Password is correct.
' write code below here.
End If
DBConnection.Close()

Conclusion:

Use to get result of Queries like count, min, max...

Friday, March 24, 2006

Solution: AccessDataSource control generates error for autoincrement data type field while Inserting a record.

Following error you may faced:

"You tried to assign the Null value to a variable that is not a Variant data type. "


Solution:

When you use AccessDataSource control to insert a record in database. If one of field type is autoincrement then above error will shoot on the screen.

Normally you remove autoincrement data type fields from InsertCommand. This creates another problem. You don't face any error, but data is not saved in respective fields in database.

So here is a solution.

First, remove autoincrement field from InsertCommand.

Second, Important step, remove autoincrement field line from InsertParameters section of AccessDataSource control.

Tuesday, February 21, 2006

Disclaimer

The views expressed on this weblog are mine and do not necessarily reflect the views of my employer.

All postings are provided "AS IS" with no warranties, and confer no rights.

Tuesday, February 14, 2006

UPGRADE ASP.NET 2.0: New Code Behind Model

In ASP.NET 1.x, the code-behind file was a class file that inherited the System.Web.UI.Page class, and the web page inherited the code-behind file. As a result, all the controls that appeared on the page were declared in the code-behind file so they would be available to both the code-behind file and page file.

Visual studio added a declaration to the code-behind file for each control. This declaration was placed in a region of the code-behind file which hidden. It was to hard to sync code-behind with page. Any control deletion, change in control name in page file might not affect the code region in code-behind file.

The new code-behind file not includes any hidden code region. Instead, the new model uses a partial class feature in VB 2005. Due to this control declarations are placed in separate file that's compiled together with the code-behind file to create final code-behind class file. All declarations created at compiled time by ASP.NET. So no mess-ups occurred.

Advantage is easier to keep the web page file in synchronization with the code-behind file.

Tuesday, February 07, 2006

VB.NET Bug: Toolbar Buttons Show No Text or Images in run time, although they appear correct at design time

Solution:
1. Expand the "Windows Form Designer generated code" section in the code view of the form.
2. Find out following statement in intializecomponents. (Replace Toolbar with actual toolbar control name)

ToolBar.Buttons.AddRange(...);

3. Cut above single line statement and Paste that statement of code at the end, after all of the properties of that ToolBar control have been set. [IMP: If Image list is used then paste above line after imagelist code block]

This will solve the problem.

[IMP: adding new controls or events, cause the IDE to regenerate the code, so the statement that causes the problem returns to its original location. Therefore, every time that you build and test the application, check the code file to make sure that above statement has been moved at the end]

Saturday, January 28, 2006

Maintain State (persistence) in ASP .NET

Here I described benefits and limitations of using various technique to store state:
These techniques are other than InProc and OutProc(SQL Server) in web.config file.

1. Hidden Fields
2. View State
3. Hidden Frames
4. Cookies
5. Query Strings

one by one ...

1. Hidden Fields:

Benifits:
A. All browser support Hidden Fields.
B. Simpler to implement. (HTML hidden type tag)
C. As data is cached on client side they work with web farms.
D. No server side resources allocated.

Limitations:
A. Page performances decreases if you store large amount of data in a page.
B. Not Secured.
C Accept only single value per tag.


2. View State:

Benefits:
A. No server resources allocated.
B. Simple to implement.
C. States are retained automatically. (You can control wise enable/disable viewstate as per requirement)
D. Values stored in encoded fashion. More secure than hidden fields.
E. Good for caching data in Web Farm. (Same as hidden fields, clientside)

Limitations:
A. Page performance and loading speed decreases if larger amount of data is stored. (Like Gridview data)
B. View state stores data in HTMl Hidden field on page so even if data is encoded not complete secure.


3. Hidden Frames:

Benefits:
A. You can cache more than one data field.
B. The ability to cache and access data items stored in different hidden forms.
C. The ability to access JScript variable values stored in different frames if they come from same site.

Limitations:
A. Not supported by all browsers.
B. Stored data can be tampered.


4. Cookies:

Benefits:
A. No server resources are required to store data.
B. Light weight and simple to use. (to Write and read)


Limitations:
A. Limited size to store data 4096 byte or 8192 bytes.
B. User can disable cookies.
C. Cookies can be tampered.
D. Cookies expiry leads towards inconsistency.


5. Query String:

Benefits:
A. No server resources required.
B. All browser supports.


Limitations:
A. Values directly visible to user.
B. Limit is upto 255 characters for most browsers. (URL Length)

Monday, January 23, 2006

Data Type Naming Conventions.


Data TypeExamplePrefix
Boolean
blnResult
bln
Byte
bytByte
byt
Char
chrCase
chr
Date
datStart
dat
Double
dblSum
dbl
Decimal
decAveragedec
Integer
intEmpId
int
Long
lngCounter
lng
Single
sngStock
sng
Short
shoShort
sho
String
strName
str
Most commonly used Hungarian Notations for data types. First three letters of a variable name to distinguish subtype. The fourth letter of the variable is then typed in uppercase, to indicate that this where the actual variable name starts.

Sunday, January 22, 2006

ASP .NET Control Naming Conventions

Control NameExamplePrefix
LabellblNamelbl
TextBoxtxtNametxt
GridViewgvResultgv
ButtonbtnSavebtn
ImageButtonibtnSaveibtn
HyperlinklnkHomePagelnk
DropDownListddlCompanyddl
ListBoxlstCompanylst
DataListdlstAddressdlst
RepeaterrepSectionrep
CheckboxchkMailListchk
CheckBoxListchkAddresschk
RadioButtonrdoSexrdo
RadioButtonListrdoAgeGrouprdo
ImageimgLogoimg
PanelpanSectionpan
PlaceHolderplhHeaderplh
CalendercalMyDatecal
AdrotatoradrBanneradr
TabletblResultstbl
[All]ValidatorsvalCreditCardNumberval
ValidationSummaryvalsErrorsvals

Saturday, January 14, 2006

.NET, VB.NET, ASP.NET Questions with small hints:

Q. What is base class in .NET?

Hint: System.Object

Q. What is main difference between ASP and ASP.NET?

Hint: In ASP (i.e. classic one) scripts/code is not complied. ASP.NET come with nice feature code behind.

Q. Name some languages supported by .NET?

Hint: VB.NET, Visual J#, Visual C#, Visual C++

Q. What is assembly?

Hint: Deployment Units. Assemblies are similar to DLL files. Both have the reusable pieces of code in the form of classes/ functions. DLL needs to be registered but assemblies have its own metadata (i.e. includes name and version of the assembly, security information, information about the dependencies and the list of files that constitute the assembly).

Q. Difference between Panel and Group box?

Hint: Panel is scrollable. In panel you can’t set caption like Group box.

Q. What’s the difference between Response.Write() andResponse.Output.Write()?

Hint: Response.Output.Write() allows you to write formatted output.

Q. What is Delegate?

Hint: Delegate is like a pointer to a function in C++ or like an event handler in Java

You can use it to “multicast” which means running multiple functions in different instances of object already created.

This is useful when you want your objects to “register” to an event raised by another object.

The way it works is the object you are registered to listen to receive the delegate of the function it is supposed to run in your object, the delegate is then run from it. (If you switch the word delegate for pointer, this would be much simpler)

Q. What is serialization?

Hint: Serialization is when you persist the state of an object to a storage medium so an exact copy can be re-created at a later stage. Serialization is used to save session state in ASP.NET. Serialization is to copy objects to the Clipboard in Windows Forms Serialization is used by remoting to pass objects by value from one application domain to another.

Q. What is Viewstate?

Hint: Server control’s view state is the accumulation of all its property values. In order to preserve these values across HTTP requests, ASP.NET server controls use this property, which is an instance of the StateBag class, to store the property values.

Q. Where Viewstate is stored?

Hint: Viewstate is stored in the hidden field __VIEWSTATE.

Q. What is an Abstract class?

Hint: An abstract class is a special kind of class that cannot be instantiated. So the question is why we need a class that cannot be instantiated? An abstract class is only to be sub-classed (inherited from). In other words, it only allows other classes to inherit from it but cannot be instantiated. The advantage is that it enforces certain hierarchies for all the subclasses. In simple words, it is a kind of contract that forces all the subclasses to carry on the same hierarchies or standards.

Q. What is an Interface?

Hint: An interface is not a class. It is an entity that is defined by the word Interface. An interface has no implementation; it only has the signature or in other words, just the definition of the methods without the body. As one of the similarities to Abstract class, it is a contract that is used to define hierarchies for all subclasses or it defines specific set of methods and their arguments. The main difference between them is that a class can implement more than one interface but can only inherit from one abstract class

Q. Describe the role of inetinfo.exe, aspnet_isapi.dll andaspnet_wp.exe in the page loading process.

Hint: inetinfo.exe is the Microsoft IIS server running, handling ASP.NET requests among other things. When an ASP.NET request is received (usually a file with .aspx extension), the ISAPI filter aspnet_isapi.dll takes care of it by passing the request to the actual worker process aspnet_wp.exe.

Q. What’s a bubbled event?

Hint: When you have a complex control, like DataGrid, writing an event processing routine for each object (cell, button, row, etc.) is quite tedious. The controls can bubble up their eventhandlers, allowing the main DataGrid event handler to take care of its constituents.

Q. Explain the differences between Server-side and Client-side code?

Hint: Server-side code executes on the server. Client-side code executes in the client's browser.

Wednesday, January 11, 2006

LIST OF NEW CONTROLS IN ASP.NET 2.0

(Category wise list)

(I) View Controls:

1. MultiView

2. View

3. FormView

4. DetailsView

5. GridView

6. LoginView

7. TreeView

(II) DataSource Controls

1. SqlDataSource

2. AccessDataSource

3. XMLDataSource

4. ObjectDataSource

5. SiteMapDataSource

(III) Navigation Controls

1. SiteMapPath

2. TreeView

(IV) Login Controls:

1. LoginStatus

2. LoginView

3. ChangePassword

4. PasswordRecovery

5. LoginName

6. CreateUserWizard

(V) WebPart Controls:

1. WebPartManager

2. WebPartZone

3. CatalogZone (contains DeclarativeCatalogPart, PageCatalogPart, and ImportCatalogPart)

4. EditorPart controls (contains AppearanceEditorPart, BehaviorEditorPart, LayoutEditorPart, and PropertyGridEditorPart

5. EditorZone

6. ConnectionZone

7. ConnectionPart

8. ProxyWebPartManager

(VI) Report Controls:

1. ReportViewer

2. CrystalReportPartsViewer

3. CrystalReportSource

Monday, January 09, 2006

Posting to Other Pages - ASP.NET 2.0

Posting to other pages or cross page posting is now possible in ASP.NET 2.0. This is a new feature over ASP.NET 1.0 and 1.1.

Following code snippet will give you clear-cut idea.

Here button tag to have an attribute called 'PostbackUrl' that post to another page.

Sunday, January 01, 2006

Happy New Year

Hi Friends
Wish you all a very happy and prosperous new year.
Bye

Visitor Count: