Search This Blog

Thursday, November 1, 2012

Session Timeout asp.net web.config

ASP.NET > Session > Timeout

The Timeout property specifies the time-out period assigned to the Session object for the application, in minutes. If the user does not refresh or request a page within the time-out period, the session ends.
The default is 10 minutes.
Should not be lower than 4 minutes an higher than 20 minutes.

<sessionstate timeout="30">





Disable Back Button Interrnet Browser Asp .net

ASP.NETDisable Back Button IE

HttpCacheability.NoCache
Sets the Cache-Control: no-cache header

SetNoStore
Sets the Cache-Control: no-store HTTP header.

Example:

Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();






NEWID SQL Server

SQL Server > Built-In Functions > NEWID

Creates a unique value of type uniqueidentifier.

Example

DECLARE @myid uniqueidentifier
SET @myid = NEWID()

update
 user
set
 app_token = @myid
where
 id = 1






SET ANSI_NULLS SQL Server

Specifies ISO compliant behavior of the Equals (=) and Not Equal To (<>) comparison operators when they are used with null values.

SET ANSI_NULLS { ON | OFF }

When SET ANSI_NULLS is ON, a SELECT statement that uses WHERE column_name = NULL returns zero rows even if there are null values in column_name.

When SET ANSI_NULLS is OFF, the Equals (=) comparison operators do not follow the ISO standard. A SELECT statement that uses WHERE column_name = NULL returns the rows that have null values in column_name.





Wednesday, October 24, 2012

How to add HyperLink Column to Telerik RadGrid Code Behind

Telerik > RadGrid > GridHyperLinkColumn





Each row in a Hyperlink column will contain a predefined hyperlink. This link is not the same for the whole column and can be defined for each row individually.

DataNavigateUrlFields: Gets or sets a string, representing a comma-separated enumeration of DataFields from the data source, which will form the url of the windwow/frame that the hyperlink will target.

DataNavigateUrlFormatString: Gets or sets a string, representing a comma-separated enumeration of DataFields from the data source, which will form the url of the windwow/frame that the hyperlink will target.
Example:
Add hyperlink column to RadGrid programmatically

RadGrid grd = new RadGrid();
GridHyperLinkColumn linkColumn = new GridHyperLinkColumn();
string[] fld = { "id" };
linkColumn.DataNavigateUrlFields = fld;
linkColumn.DataNavigateUrlFormatString = "Default.aspx?ID={0}";
linkColumn.HeaderText = "Id";
grd.Columns.Add(linkColumn);









DataTable.Select Method (String) c#

C# > Data   > DataTable > Select

DataTable Select method gets an array of all DataRow objects that match the filter criteria.
If the column on the filter contains a null value, it will not be part of the result.

Example:

private void FilterDataTable(string filter)
{
    DataTable table = DataSet1.Tables["Person"];
    DataRow[] foundRows;

    // Use the Select method to find all rows matching the filter. Sample: filter = "name = 'dan' "
    foundRows = table.Select(expression);
    for(int i = 0; i < foundRows.Length; i ++)
    {
        Console.WriteLine(foundRows[i][0] );
    }
}






Wednesday, October 17, 2012

How to exit for C#

C# > Statements > break

How to exit for C#? The answer is break.
The break statement terminates the closest enclosing loop or switch statement in which it appears. Control is passed to the statement that follows the terminated statement.

Example:

for (int j = 0; j < list.Count; j++)
{
    if (j==5)
       break;
}