Sunday, August 31, 2008

RegularExpressionValidator Control

RegularExpressionValidator Control

The RegularExpressionValidator control performs its validation based on a regular expression. A regular expression is a powerful pattern-matching language that can be used to identify simple and complex character sequences that would otherwise require writing code to accomplish. This ValidationExpression property is set to a valid regular expression that is applied to the data that is to be validated. The data is validated
if it matches the regular expression.

RangeValidator Control

RangeValidator Control

->The RangeValidator control is used to verify that the data to be validated is within a specified range of values. To use this control effectively, you must set the Minimum-Value, MaximumValue, and the Type properties.

->The Type property causes the data to be converted to the proper data type prior to checking the range. The Type property defaults to String, so you must set the Type property to achieve proper range validation. For example, if you don’t set the Type property, it defaults to String, and if a numeric range is being checked from 3 to 30, only strings that begin with the string letter 3 are considered valid.

CompareValidator Control

CompareValidator Control

->The CompareValidator control performs its validation by using comparison operators such as greater than and less than to compare the data with a constant or a value in a different control. In addition, the CompareValidator can verify that the data is of a certain type, such as a date.

->The ValueToCompare property can be set to a constant that is used to perform the comparison.

->The Operator property defines how to perform the comparison and can be set to Equal, NotEqual, GreaterThan, GreaterThanEqual, LessThan, LessThanEqual, or DataTypeCheck.

->The ControlToCompare property can be set to a control that is used to perform the comparison.

->This property takes precedence if this property and the ValueToCompare properties are both set.

BaseCompareValidator Class

BaseCompareValidator Class

The RangeValidator and CompareValidator inherit from the BaseCompareValidator control,
which contains common comparison behavior that is used by these controls.
The BaseCompareValidator contains the Type property, which you can set to the data type that the text is converted to before a comparison is made. The data types that are available are as follows:

->Currency The data is validated as System.Decimal, but currency symbols and grouping characters also can be entered.
->Date The data is validated as a numeric date.
->Double The data is validated as System.Double.
->Integer The data is validated as System.Int32.
->String The data is validated as System.String.

RequiredFieldValidator Control

RequiredFieldValidator Control

The RequiredFieldValidator is used to ensure that the user has placed non–white space data into a control. The other controls do not attempt to validate an empty field, so you frequently need to use the RequiredFieldValidator with one of the other controls to achieve the desired validation.
The RequiredFieldValidator provides an additional property called InitialValue that is used when the control that you are validating defaults to a value and you want to ensure that the user changes this value. For example, if you normally display a zero
(0) value in a control for the age and you want to ensure that the user changes the age, set the InitialValue to zero so a validation error occurs if the user leaves the default value of the control set to zero.

Thursday, August 28, 2008

Data Access Class C#.NET with Maximum DATABASE

DATA ACCESS CLASS C#.NET with Maximum Database.

it can use with maximum database, sliding change.


using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;

namespace Banglar_Dalan
{
class DataAccess
{
static string _ConnectionString = @"Data Source=.\SQLEXPRESS;
AttachDbFilename=|DataDirectory|\DatabaseName.mdf;
Integrated Security=True;
Connect Timeout=30;
User Instance=True";

static SqlConnection _Connection = null;
public static SqlConnection Connection
{
get
{
if (_Connection == null)
{
_Connection = new SqlConnection(_ConnectionString);
_Connection.Open();

return _Connection;
}
else if (_Connection.State != System.Data.ConnectionState.Open)
{
_Connection.Open();

return _Connection;
}
else
{
return _Connection;
}
}
}

public static DataSet GetDataSet(string sql)
{
SqlCommand cmd = new SqlCommand(sql, Connection);
SqlDataAdapter adp = new SqlDataAdapter(cmd);

DataSet ds = new DataSet();
adp.Fill(ds);
Connection.Close();

return ds;
}

public static DataTable GetDataTable(string sql)
{
Console.WriteLine(sql);
DataSet ds = GetDataSet(sql);

if (ds.Tables.Count > 0)
return ds.Tables[0];
return null;
}

public static int ExecuteSQL(string sql)
{
SqlCommand cmd = new SqlCommand(sql, Connection);
return cmd.ExecuteNonQuery();
}
}
}


It just for Archiving.

Wednesday, August 27, 2008

The RadioButton Control[Common Web Server Controls]

The RadioButton Control

1.The RadioButton control gives the user the ability to select between mutually exclusive RadioButton controls in a group. To group multiple RadioButton controls together, specify the same GroupName for each RadioButton control. Grouping radio buttons together only allows a mutually exclusive selection from the group.

Security Alert Populating the RadioButton control’s Text property with data from an untrusted source can create Cross Site Scripting (XSS) vulnerabilities. Use the HttpUtility.HtmlEncode or Server.HtmlEncode method to encode the untrusted data that is placed in the Text property.

2.The RadioButton control’s Text property specifies its caption. Use the TextAlign property
to specify the side that the caption appears on. The Checked property is used to set and get the status of the RadioButton control.

The CheckBox Control[Common Web Server Controls]

The CheckBox Control

1.The CheckBox control gives the user the ability to select between true and false. The CheckBox control’s Text property specifies its caption. Use the TextAlign property to specify on which side that the caption appears. The Checked property is used to set and get the status of the CheckBox control.

Security Alert Populating the CheckBox control’s Text property with data from an untrusted source can create Cross Site Scripting (XSS) vulnerabilities. Use the HttpUtility.HtmlEncode or Server.HtmlEncode method to encode the untrusted data that is placed in the Text property.

2.The CheckedChanged event is raised when the state of the CheckBox control changes, but by default, the AutoPostBack property of the CheckBox control is set to false. This means that changing the checked state does not cause a PostBack, but the Check-Changed event is raised when another control performs a PostBack.

The Button Control[Common Web Server Controls]

The Button Control

1.The Button control displays a push button on the Web page that the user can click to trigger a PostBack to the Web server. A Button can be either a submit (default) button or a command button.

A submit button does not have its CommandName property set and simply performs a PostBack to the server. You provide an event handler for the Click event to control the actions performed when the user clicks the submit button.
You can use a Button as a command button by assigning a command name, such as ChangeChannel or FastFoward, to the CommandName property. Using the Command-Name property allows you to create multiple Button controls on a Web page; you can programmatically determine which button is clicked in the event handler for the Command
event. You can also use the CommandArgument property to provide additional information about the command to perform, such as ChannelUp, ChannelDown, x2 (FastForward x 2), or x3 (FastForward x 3). Simply provide an event handler for the Command event to control the actions performed when a command button is clicked.

2.The Button control also contains a CausesValidation property that is set to true by default, which causes page validation to be performed when a Button control is clicked. Set the CausesValidation property to false when you want a button to bypass validation. Reset and help buttons are examples of buttons that typically bypass validation.

The TextBox Control [Common Web Server Controls]

The TextBox Control

1.The TextBox control collects text from the user. The Text property gets or sets the contents of the TextBox control.

2.The TextBox contains a TextMode property that you can set to SingleLine (default), MultiLine, or Password. SingleLine allows the user to enter a single line of text, Multi-Line allows the user to enter many lines of text, and Password creates a single-line text box that masks the value entered by the user.

3.The Columns property sets the maximum width of the TextBox; the Rows property sets the maximum height of a multiline TextBox.

4.The MaxLength property limits the number of characters that can be entered; the Wrap property automatically continues the text on the next line when the end of the text box is reached.

The Label Control[Common Web Server Controls]

The Label Control

1.The Label control displays text at a specific location on the Web page using the properties
that the control has been assigned. Use the Label control when server code changes the text or the properties. If you only need to display static text, use HTML or the Literal control instead of using a Label control. The Literal control also displays text and the text can be changed by server code, but the Literal control does not support
styles, themes, and skins.

2.Labels can be used as the caption of the TextBox or other controls in a situation where using the access key for the Label moves the focus to the control to the right of the Label.