ASP.NET

How to use ViewState in C#

You as software developer can use code to add information directly to the view state collection of the containing page and recover it later after the page is posted back. The type of information you can store includes not only the simple data types, but your custom objects too.   The view state collection is provided by ViewState property …

Learn more

How to encrypt connection string in Web.config file

1. Run the ASP.NET IIS registration tool (aspnet_regiis.exe). The following example shows how to encrypt the connectionStrings section of the Web.config file for an application named SampleApplication:

aspnet_regiis -pe “connectionStrings” -app “/SampleApplication”

2. Determine the user account or identity under which ASP.NET runs by retrieving the current WindowsIdentity name:

<%@ Page Language=”C#” %><%Response.Write(System.Security.Principal.WindowsIdentity.GetCurrent().Name);%>

3. Grant the NETWORK SERVICE account access to the …

Learn more

How to use pager in GridView control

The GridView control displays a pager bar when the AllowPaging property is set to true. Developer can control characteristics of the pager to a large extent, through the <PagerSettings> and <PagerStyle> tags or their equivalent properties. The GridView control’s pager supports first and last page buttons and lets developer assign an image to each button.  The pager can …

Learn more

Events in GridView control

Event
Description

PageIndexChanging, PageIndexChanged
Both events arise when one of the pager buttons is clicked. They fire before and after the grid control handles the paging operation.

RowCancelingEdit
The event arises when the Cancel button of a row in edit mode is clicked, but before the row exits edit mode.

RowCommand
Arises when …

Learn more

Template properties of GridView control

Property

Type

Description

EmptyDataTemplate

 

ITemplate

The property is used to indicate the template content to be rendered when the control is bound to an empty source. This property takes precedence over EmptyDataText if both are set. If neither is set, the grid isn’t rendered if bound to an empty data source.

PagerTemplate

 

ITemplate

The property …

Learn more

Style properties of GridView control

Property

Type

Description

AlternatingRowStyle

TableItemStyle

You can use this property to get a reference to the TableItemStyle object that enables you to define the style properties for every other row in the table.

EditRowStyle

TableItemStyle

You can use this property to get a reference to the TableItemStyle object that enables you to define the style properties …

Learn more

State properties of GridView control

Property

Type

Description

BottomPagerRow

GridViewRow

The property is used to get a GridViewRow object that represents the bottom pager row in the control.

Columns

DataControlFieldCollection

 

You can use the property to get a collection of objects that represent the columns in the control. If columns are auto-generated the collection will be empty. From the DataControlFiled class …

Learn more

Visual properties of GridView control

Property

Type

Description

BackImageUrl

string

Use it to get or set the URL to an image to display in the background

Caption

string

The property is used to get or set the text to render in an HTML caption element in a GridView control. With this property you can make the control more accessible to users of assistive …

Learn more

Behavioral properties of GridView control

Property
Type
Description

AllowPaging
bool
The control will support paging if you set it to true

AllowSorting
bool
The control will support sorting if you set it to true

AutoGenerateColumns
bool
By default its value is true i.e. columns will be automatically created for each filed in the data source.

AutoGenerateDeleteButton
bool
If you set it to true the control will include a button …

Learn more

How to send email in C#

Read the full ASP.NET tutorial at how to send email.

Related TutorialsHow to search XML content with XmlDocument in VB.NET
How to download a file from the Web server in ASP.NET in C#
How to create an ASP.NET web-page client for a web service in VB.NET
How to store custom objects in a View state using C#
How to use timeout property of …

Learn more