Page Directives
@Page
@Assembly
@Import
@Control
@Implements
@Master
@MasterType
@OutputCache
@PreviousPageType
@Reference
@Register
Page Events
PreInit
Init
InitComplete
PreLoad
Load
LoadComplete
PreRender
PreRenderComplete
Unload
Asp.net Application Folders
\App_Code
\App_Data
\App_Themes
\App_GlobalResources
\App_LocalResources
\App_WebReferences
\App_Browsers
Global.asax events
Application_Start
Session_Start
Application_BeginRequest
Application_AuthenticateRequest
Application_Error
Session_End
Application_End
Working with Javascript
1. using control’s ID
2. using Page.ClientScript.RegisterClientScriptBlock
3. using Page.ClientScript.RegisterStartupScript
4. using Page.ClientScript.RegisterClientScriptInclude
Hot Key
using: AccessKey = ” ” AssociatedControlID = ” ”
IE already uses Alt+F, E, V, I, O, T, A, W, H
Web Server Controls
Label, Literal, TextBox, Button, LinkButton, ImageButton, HyperLink,
DropDownList, ListBox, CheckBox, CheckBoxList, RadioButton, RadioButtonList
Image, Table, Calendar, AdRotator, XML, Panel, PlaceHolder
2.0: BulletedList, HiddenField, FileUpload, MultiView/View, Wizard, ImageMap
Validation Controls
RequiredFieldValidator
CompareValidator
RangeValidator
RegularExpressionValidator
CustomVlidator
ValidationSummary
Data Source Controls
SqlDataSource, ObjectDataSource, XmlDataSource, SiteMapDataSource
Bound List Controls
GridView, DetailsView, FormView
DataBinder Syntax
<%# Container.DataItem(”Name”) %>
<%# Eval(”Name”) %>
<%# Bind(”Name”) %>
Application Structure
namespace ConsoleApplication1
{
class Class1
{
[STAThread]
static void Main(string[] args)
{ … … }
}
}
Block
{ … … ; … … ; }
Comment
/* … … */
// … …
/// … …
Variables
sbyte, byte, short, ushort, int, uint, long, ulong
float, double, decimal
char, bool, string
Escape
\’ , \” , \\ , \0 , \a , \b . \f , \n , \r , \t , \v
or use @”… …”
Mathematical Operators
+, -, *, /, %, ++, –
Assignment Operators
=, +=, -=, *=, /=, %=
Boolean Logic
==, !=, <, >, <=, >=, !, &, |, ^, &&, ||
Bitwise Operators
&, |, >>, <<
Boolean Assignment Operators
&=, |=, ^=, >>=, <<=
Goto Statement
goto myLabel;
myLabel: … …
Ternary Operator
(condition) ? resultiftrue : resultiffalse
IF Statemt
if ( … ) { … … } else { … … }
Switch Statemt
switch ( … )
{
case val1: … …; break;
case val2: … …; break;
default: … …; break;
}
Loops Statemt
do { … … } while ( … );
while ( … ) { … … }
for ( initialization; condition; operation ) { … … }
foreach (type name in array) { … … }
interrupting loops: break, continue, goto, return
Type Conversion
Convert.ToBoolean/ToByte/ToChar/
ToDecimal/ToDouble/ToInt16/ToInt32/ToInt64/
ToSByte/ToSingle/ToString/ToUInt16/ToUInt32/ToUInt64(val)
or use (Type)val
Enumerations
enum typeName : underlyingType { val1, val2, valn }
typeName varName;
varName = typeName.value;
Structs
struct structName
{
accessibility type name;
}
Arrays
type[] name = {, , , };
name[i] = value;
type[, , ,] name = {{, , }, {, , } … …};
name[i, j] = value;
Strings
string.ToCharArray();
string.ToLower/ToUpper();
string.Trim/TrimStart/TrimEnd()
string.PadLeft/PadRight(desiredLength);
string.Split(separator);
Debug
try { … … }
catch ( exceptionType e) { … … }
finally { … … }