ASP.NET > Web > HttpResponse > IsClientConnected
The IsClientConnected property is a read-only property that indicates if the client has reset the connection to the server.
This property enables you greater control over circumstances where the client may have reset the connection to the server. For example, if a long period of time has elapsed between when a client request was made and when the server responded, it may be beneficial to make sure the client is still connected before continuing with something.
Example
If Not Response.IsClientConnected Then
Response.Redirect("login.aspx")
End if
Search This Blog
Thursday, December 13, 2012
Response.Redirect asp.net
Redirects a client to a new URL. Specifies the new URL and whether execution of the current page should terminate.
bool continue;
// some code
if (continue)
{
Response.Redirect("page.aspx", false);
}
else
{
Response.End();
}
Parameters
- url
- The target location.
- endResponse
- Indicates whether execution of the current page should terminate.
bool continue;
// some code
if (continue)
{
Response.Redirect("page.aspx", false);
}
else
{
Response.End();
}
Etichete:
asp.net
HttpCookie asp.net
ASP.NET > HttpCookie
The HttpCookie class gets and sets properties of individual cookies.
HttpCookie loginCookie = Request.Cookies.Get("loginCookie");
if (loginCookie == null)
{
loginCookie = new HttpCookie("loginCookie");
loginCookie.Value = txtUsr.Text;
loginCookie.Expires = DateTime.Now.AddDays(15);
Response.Cookies.Add(loginCookie);
}
The HttpCookie class gets and sets properties of individual cookies.
HttpCookie loginCookie = Request.Cookies.Get("loginCookie");
if (loginCookie == null)
{
loginCookie = new HttpCookie("loginCookie");
loginCookie.Value = txtUsr.Text;
loginCookie.Expires = DateTime.Now.AddDays(15);
Response.Cookies.Add(loginCookie);
}
Sunday, December 9, 2012
OBJECT_ID SQL Server
SQL Server > Built-in Functions > OBJECT_ID
OBJECT_ID returns the database object identification number of a schema-scoped object.
Example:
IF OBJECT_ID (N'dbo.tbl1', N'U') IS NOT NULL
DROP TABLE dbo.tbl;
GO
OBJECT_ID returns the database object identification number of a schema-scoped object.
Example:
IF OBJECT_ID (N'dbo.tbl1', N'U') IS NOT NULL
DROP TABLE dbo.tbl;
GO
Etichete:
SQL Server
SET XACT_ABORT SQL Server
SQL > Set Statements > XACT_ABORT
Specifies whether SQL Server automatically rolls back the current transaction when a Transact-SQL statement raises a run-time error.
Syntax:
SET XACT_ABORT { ON | OFF }
Example
IF OBJECT_ID(N'tbl1', N'U') IS NOT NULL
DROP TABLE tbl1;
GO
IF OBJECT_ID(N'tbl2', N'U') IS NOT NULL
DROP TABLE tbl2;
GO
CREATE TABLE tbl1
(fld1 INT NOT NULL PRIMARY KEY);
CREATE TABLE tbl2
(fld2 INT NOT NULL REFERENCES tbl1(fld1));
GO
INSERT INTO tbl1 VALUES (1);
INSERT INTO tbl1 VALUES (2);
INSERT INTO tbl1 VALUES (3);
INSERT INTO tbl1 VALUES (4);
GO
SET XACT_ABORT OFF;
GO
BEGIN TRANSACTION;
INSERT INTO tbl2 VALUES (1);
INSERT INTO tbl2 VALUES (2);
INSERT INTO tbl2 VALUES (5); -- Foreign key error. SELECT shows only values 1 and 2 inserted. -- Values 5 insert failed and was rolled back, but
-- XACT_ABORT was OFF and rest of transaction
-- succeeded.
COMMIT TRANSACTION;
GO
SET XACT_ABORT ON;
GO
BEGIN TRANSACTION;
INSERT INTO tbl2 VALUES (3);
INSERT INTO tbl2 VALUES (5); -- Foreign key error.
-- Values 5 insert error with XACT_ABORT ON caused
-- all of the second transaction to roll back.
INSERT INTO tbl2 VALUES (4);
COMMIT TRANSACTION;
GO
SELECT * FROM tbl2;
GO
Specifies whether SQL Server automatically rolls back the current transaction when a Transact-SQL statement raises a run-time error.
Syntax:
SET XACT_ABORT { ON | OFF }
Example
IF OBJECT_ID(N'tbl1', N'U') IS NOT NULL
DROP TABLE tbl1;
GO
IF OBJECT_ID(N'tbl2', N'U') IS NOT NULL
DROP TABLE tbl2;
GO
CREATE TABLE tbl1
(fld1 INT NOT NULL PRIMARY KEY);
CREATE TABLE tbl2
(fld2 INT NOT NULL REFERENCES tbl1(fld1));
GO
INSERT INTO tbl1 VALUES (1);
INSERT INTO tbl1 VALUES (2);
INSERT INTO tbl1 VALUES (3);
INSERT INTO tbl1 VALUES (4);
GO
SET XACT_ABORT OFF;
GO
BEGIN TRANSACTION;
INSERT INTO tbl2 VALUES (1);
INSERT INTO tbl2 VALUES (2);
INSERT INTO tbl2 VALUES (5); -- Foreign key error. SELECT shows only values 1 and 2 inserted. -- Values 5 insert failed and was rolled back, but
-- XACT_ABORT was OFF and rest of transaction
-- succeeded.
COMMIT TRANSACTION;
GO
SET XACT_ABORT ON;
GO
BEGIN TRANSACTION;
INSERT INTO tbl2 VALUES (3);
INSERT INTO tbl2 VALUES (5); -- Foreign key error.
-- Values 5 insert error with XACT_ABORT ON caused
-- all of the second transaction to roll back.
INSERT INTO tbl2 VALUES (4);
COMMIT TRANSACTION;
GO
SELECT * FROM tbl2;
GO
Etichete:
SQL Server
Saturday, December 1, 2012
date datatype SQL Server
SQL Server > Data Types > Date
Default format: YYYY-MM-DD
Range: 0001-01-01 through 9999-12-31
Example
DECLARE @date1 date
CREATE TABLE Table1 ( datefield date )
-- difference between date and datetime
DECLARE @date date= '12-10-21';
DECLARE @datetime datetime= @date;
SELECT @date AS 'date', @datetime AS 'datetime';
--Result
--date datetime
------------ -----------------------
--2021-12-10 2021-12-10 00:00:00.000
Other Examples
Default format: YYYY-MM-DD
Range: 0001-01-01 through 9999-12-31
Example
DECLARE @date1 date
CREATE TABLE Table1 ( datefield date )
-- difference between date and datetime
DECLARE @date date= '12-10-21';
DECLARE @datetime datetime= @date;
SELECT @date AS 'date', @datetime AS 'datetime';
--Result
--date datetime
------------ -----------------------
--2021-12-10 2021-12-10 00:00:00.000
Other Examples
Etichete:
SQL Server
Friday, November 30, 2012
How to change colums color to RadGridView (VB.NET)
Telerik > RadGridView > Cell Formatting
CellFormatting event is used to add formatting to grid cells
Imports Telerik.WinControls.UI
Imports Telerik.WinControls
Private Sub grd_CellFormatting(sender As System.Object, e As Telerik.WinControls.UI.CellFormattingEventArgs) Handles grd.CellFormatting
If e.CellElement.ColumnInfo.Name = "total" Then
e.CellElement.ForeColor = Color.Blue
Else
e.CellElement.ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local)
End If
End Sub
CellFormatting event is used to add formatting to grid cells
Because of UI virtualization in RadGridView, cell elements are created only for currently visible cells. To prevent applying the formatting to other columns' cell elements all customization should be reset for the rest of the cell elements. Example: Change Forecolor in CellFormating Events |
Imports Telerik.WinControls.UI
Imports Telerik.WinControls
Private Sub grd_CellFormatting(sender As System.Object, e As Telerik.WinControls.UI.CellFormattingEventArgs) Handles grd.CellFormatting
If e.CellElement.ColumnInfo.Name = "total" Then
e.CellElement.ForeColor = Color.Blue
Else
e.CellElement.ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local)
End If
End Sub
Etichete:
Telerik
Subscribe to:
Posts (Atom)