Category Archives: ASP.NET & C#

This category has articles regarding asp and asp.net

javascript value in server side variable

You can get variable from javascript and use it in code behind code in dotnet variable it means server side variable.
Dim strMessage2 As String = “”
Response.Write(“var str1 =
prompt(‘Please Enter Password:’,”);”)
strMessage2 = “document.write(str1);”
Response.Write(strMessage2)

Calling postback event from Javascript

SOURCE : http://www.dotnetspider.com/resources/1521-How-call-Postback-from-Javascript.aspx
Introduction
Postback is a concept introduced in ASP.NET and is a very handy method. Postback is built into the ASP.NET and most of the web controls support it without writing any code.
Calling postback event from Javascript
There may be some scenario where you may want to explicitly postback to the server using some clientside javascript. [...]

Data Type Mapping

Mapping data types into different environments like .Net and SQL server.

ASP.NET Control
DNN KickStart Field type
.NET
Framework
SQL
Server
ADO
DataType
Enum
ADO
DataType
Enum
Value
Size
Access
Oracle
Visual
Basic
6.0

Int64
SqlDbType.BigInt
OleDbType.BigInt
bigint
adBigInt
20
8

Variant

Byte[]
SqlDbType.VarBinary
OleDbType.Binary
binary
timestamp
adBinary
128
50
8

Raw
Variant

Yes/No
Boolean
SqlDbType.Bit
OleDbType.Boolean
bit
adBoolean
11
1
2
YesNo

Boolean

String
OleDbType.BSTR

adBSTR
8

(DataReader)

adChapter
136

Text
Document
String
SqlDbType.Char
OleDbType.Char
char
adChar
129
X

Char
String

Money
Decimal
SqlDbType.Money
OleDbType.Currency
money
smallmoney
adCurrency
6
8
4
0
Currency

Currency

DateTime
OleDbType.DBDate

adDate
7
0
DateTime

Date

DateTime
OleDbType.DBDate

adDBDate
133

DBFileTime

adDBFileTime
137

DateTime
OleDbType.DBTime

adDBTime
134

Date
Time
DateTime
SqlDbType.DateTime
OleDbType.DBTimeStamp
datetime
smalldatetime
adDBTimeStamp
135
8
4
0
DateTime
Date
Date

Decimal
OleDbType.Decimal

adDecimal
14

Decimal
Variant 6

Double
SqlDbType.Float
OleDbType.Double
float
adDouble
5
8
0
Double
Float
Double

Empty

adEmpty
0

External-Exception
OleDbType.Error

adError
10

DateTime
OleDbType.Filetime

adFileTime
64

Guid
SqlDbType.UniqueIdentifier
OleDbType.Guid
uniqueidentifier
adGUID
72
16
ReplicationID

Variant

Object
OleDbType.IDispatch

adIDispatch
9

Identifier
Number
Int32
SqlDbType.Int
OleDbType.Integer
identity
int
adInteger
3
4
4
AutoNumber
Long Integer
Int
Long

Object
OleDbType.IUnknown

adIUnknown
13

Byte[]
SqlDbType.VarBinary
OleDbType.LongVarBinary
image
adLongVarBinary
205
2147483647
OLEObject
Long Raw
Blob
Variant

String
SqlDbType.VarChar
OleDbType.LongVarChar
text
adLongVarChar
201
2147483647
Memo
Hyperlink
Long
Clob
String

String
SqlDbType.NText
OleDbType.VarWChar
ntext
adLongVarWChar
203
1073741823
Memo
Hyperlink
NClob
String

Decimal
SqlDbType.Decimal
OleDbType.Decimal
decimal
numeric
adNumeric
131
9
Decimal
Decimal
Integer
Number
SmallInt
Variant

Object
OleDbType.PropVariant

adPropVariant
138

Single
SqlDbType.Real
OleDbType.Single
real
adSingle
4
4
Single

Single

Int16,
SqlDbType.SmallInt
OleDbType.SmallInt
smallInt
adSmallInt
2
2
Integer

Integer

Byte
OleDbType.TinyInt

adTinyInt
16

UInt64
OleDbType.UnsignedBigInt

adUnsignedBigInt
21

UInt32
OleDbType.UnsignedInt

adUnsignedInt
19

UInt16
OleDbType.UnsignedSmallInt

adUnsignedSmallInt
18

Byte
SqlDbType.TinyInt
OleDbType.UnsignedTinyInt
tinyInt
adUnsignedTinyInt
17
1
Byte

Byte

adUserDefined
132

Byte[]
SqlDbType.VarBinary
OleDbType.VarBinary
varbinary
adVarBinary
204
50
ReplicationID

Variant

String
SqlDbType.VarChar
OleDbType.VarChar
varchar
adVarChar
200
X
Text
VarChar
String

Object
SqlDbType.Variant
OleDbType.Variant
sql_variant
adVariant
12
8016

VarChar2
Variant

OleDbType.VarNumeric

adVarNumeric
139

String
SqlDbType.NVarChar
OleDbType.VarWChar
nvarchar
adVarWChar
202
X
Text
NVarChar2
String

String
SqlDbType.NChar
OleDbType.WChar
nchar
adWChar
130
X

String

and the Managed Extensions for C++. The table also includes entries for the Object and String classes, for which many languages have corresponding keywords.

Category
Class name
Description
Visual Basic data type
C# data type
Managed Extensions for C++ data type
JScript data type

Integer
Byte
An [...]

Format data in asp.net using BoundColumn.DataFormatString Property

Syntax
 

Inline

<asp:boundcolumn dataformatstring = strFormat … >

Script

BoundColumn.DataFormatString = strFormat

 
Property Value
 

strFormat

A formatting string that specifies the display format of data in the column.

The property is read/write with no default value.
Remarks
Use the DataFormatString property to specify the display format for data in the column.
The data format string consists of two parts, separated by a [...]

How to: Access SQL Server Using Windows Integrated Security

©2008 Microsoft Corporation. All rights reserved.

ASP.NET
How to: Access SQL Server Using Windows Integrated Security

 http://msdn2.microsoft.com/en-us/library/72wdk8cc(printer).aspx

If your application runs on a Windows-based intranet, you might be able to use Windows integrated authentication for database access. Integrated security uses the current Windows identity established on the operating system thread to access the SQL Server database. You can then [...]

prevent you from having to POSTBACK to the server to access validator’s properties.

Source : http://forums.asp.net/p/839953/840084.aspx
This example shows how to validate the LastName textbox but only if the FirstName textbox contains a value. The first part is simply HTML tags with the form controls, the second part is simply the code for “onblur” even in the Page_Load event handler.
FIRST HTML
*****************************************************************************
<%@ Page Language=”vb” AutoEventWireup=”false” Codebehind=”WebForm1.aspx.vb” Inherits=”ValidationChange.WebForm1″%>
<!DOCTYPE HTML PUBLIC “-//W3C//DTD [...]

Difference between RegisterClientScriptBlock and RegisterStartupScript

I will try to explain the difference between RegisterClientScriptBlock and RegisterStartupScript . I have experienced the difference while I was doing some stuffs yesterday. Here is what I was doing. I had a hidden field called txtHiddenField, an update button and some tabs in my page. I also have a javascript function called DisplayTab.
function DisplayTab(tabId)
{
var [...]

Good article for performance in asp.net

Hi
I got one another code optimization for speed up asp.net application
I had one quick view but need to go for detail review to dig it (if i get time in next days tooo )…
Go over link for detail study – http://www.sitepoint.com/article/aspnet-performance-tips

Empowering Web Developers Since 1997

SitePoint Sponsor

Article
[...]

best practise for code optimization in asp.net

http://dotnetguts.blogspot.com/2007/09/best-practise-for-improving-net.html

Best Practise for Improving .NET Application Performance and Scalability
This guide provides end-to-end guidance for managing performance and scalability throughout your application life cycle to reduce risk and lower total cost of ownership. It provides a framework that organizes performance into a handful of prioritized categories where your choices heavily impact [...]

good blog which includes almost all for asp.net

I recently got chance to read and got one nice blog which includes best practices for asp.net, faq for dotnet 3.0 and also sql questions for interview preparation.
Also chapters and checklists.. its really nice experience with this blog…you should visit this..
http://dotnetguts.blogspot.com/