asp.net 3.5

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 get site name in ASP.NET

You could get the IIS site name using the GetSiteName method.

System.Web.Hosting.HostingEnvironment.ApplicationHost.GetSiteName(); 

The GetSiteName is introduced in the .NET Framework …

Learn more

How to validate email address in ASP.NET

You could validate email address using the following ASP.NET code.

using System.Text.RegularExpressions;

….

// Validate the supplied email address
if( !Regex.Match(Request.Form[“email”],
@”\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*”,
RegexOptions.None).Success)
{
// Invalid …

Learn more

How to call JavaScript from ASP.NET code behind

To call JavaScript from C# code behind you should:

1. Set the Body tag in your page/master page to runat=”server” and an id=”MyBody”.
2. Code the script tag in your page:

<script src=”MyFunction.js” type=”text/javascript”></script>

3. In the code behind attach the onload attribute to the body tag:

protected void Page_Load(object sender, EventArgs e)
{
MasterPageBodyTag = …

Learn more