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: