You are on page 1of 18

2010

.Net 2.0 fundamentals


ျမန္မာ ဘာသာျဖင္႔ ေရးသား ထားပါသည္ ။

Asp.net 2.0 ကုိ စတင္ေလ႔လာမည္႔သူမ်ား အတြက္ အခက္အခဲ မရွိေစရန္ လုိတုိရွင္း


ထိမိစြာ ဘာသာျပန္ မွ်ေ၀ေပးထားပါသည္ ။

ျပည္႔ျဖိဳးေမာင္ေမာင္
( B.C ( Tech ) ( Hons ) )
MCTS , MCPD .
Web site : http://myanmaraspnet.multiply.com
CHAPTER 1

1.1 .Net Framework


1.2 Structure of .Net Application
1.3 Asp.Net & C#.Net
1.4 Asp.Net Versions
1.5 Client Server Architecture
1.6 Type of Applications create with Asp.Net
1.7 Event Flows of Asp.net Application
1.8 Event Flows of Asp.net Page
1.9 Asp.Net File Types

CHAPTER 2

2.1 Master Page


2.2 Content Page
2.3 Web Server Controls
2.4 Asp.Net Special Folders
2.5 Data Bound Controls
2.6 Tracing Key

CHAPTER 3

3.1 Data Types


3.2 Variable Declaration and Assign
3.3 Constructor
3.4 Method and Parameters
3.5 Operator
3.6 Function and Variable Scope
3.7 C# Data Type Convertions
3.8 Statements
3.9 Loops

CHAPTER 4

4.1 Validators
4.2 Web User Control, Custom Control, Composite Control

CHAPTER 5
5.1 State Management Technologies

CHAPTER 6
6.1 ADO.Net
CHAPTER 1
1.1 .Net Framework

.Net framework အပုင


ိ ္းတြင္ မသိမျဖစ္ သိရန္လုိအပ္ေသာ CLR ( Common Language Runtime ) နွင္႔ BCL ( Base
Class Library ) တုိ႔ကုိသာ ရွင္းျပပါမည္ ။

CLR ( Common Language Runtime )

• Memory ကုိ စီမံခန္႔ခြဲျခင္း , thread မ်ား ၊ code မ်ား မွန္ကန္စြာ လုပ္ေဆာင္မွု ရွိမရွိ ၊ compilation နွင္႔
တျခားေသာ System လုပ္ေဆာင္ခ်က္မ်ားကုိ လုပ္ေဆာင္သည္ ။
• Programming Coding မ်ားကုိ Compile လုပ္ရာမွ ရရွိလာေသာ Assembly( IL+Metadata ) တုိ႔ကုိ
စက္နားလည္ေစေသာ Code ( Native Code ) သုိ႔ ေျပာင္းျခင္း ကုိလည္း CLR အတြင္းပုိင္းရွိ Just-In-Time
Compiler ၏ အကူအညီမွ တဆင္႔ ေျပာင္းလဲ လုပ္ေဆာင္ေပးသည္ ။
• Memory ေပၚတြင္ မလုိအပ္ေသာ ေနရာမ်ား ( Garbage Collection ) ကုိ အလုိေလ်ာက္ ရွင္းလင္းေပးသည္ ။
• CLR သည္ IIS ( Internet Information Service ) ေပၚတြင္ host လုပ္နုိင္သည္ ။
• CLR ၏ လုပ္ေဆာင္ခ်က္မ်ားထဲမွ အေရးပါေသာ အခ်က္ အခ်ိဳ႔ကုိသာ ေဖၚျပေပးထားပါသည္ ။

BCL ( Base Class Library )

BCL သည္ namespaces မ်ားကုိ စုစည္းထားျခင္း ျဖစ္သည္ ။ Namespace ဆုိသည္မွာ သက္ဆုိင္ရာ အုပ္စု
အမ်ိဳးအစားအလုိက္ သက္ဆုိင္ရာ function မ်ားကုိ စုစည္းထားသည္႔ သေဘာပင္ ျဖစ္သည္ ။

ဥပမာအားျဖင္႔ System , System.Data , System.Data.SqlClient စသည္တုိ႔သည္ Namespace မ်ားပင္ျဖစ္သည္ ။

က်ြန္ေတာ္တုိ႔ အေနျဖင္႔ using ကုိ အသံုးျပဳျပီး သက္ဆုိင္ရာ Namespace ကုိ ေၾကျငာရံုျဖင္႔ ထို namespace ၏
သက္ဆုိင္ရာ function ၊ events နွင္႔ properties မ်ားကုိ အလြယ္တကူ ရယူ အသံုးျပဳနိုင္သည္ ။
1.2 Structure of .Net Application

Coding တစ္ခုကို Compile လုပ္လုိက္ပါက MSIL ထြက္လာသည္ ။ MSIL ထဲတင


ြ ္ .exe or .dll ဖုိင္တုိ႔ ပါ၀င္လာသည္ ။

Assembly ( IL + Metadata ) သေဘာတရားပင္ ျဖစ္သည္ ။ ထုိအပုိင္းအထိ စက္နားလည္္ေသာ Code မျဖစ္ေသးပါ ။


CLR ၏ အကူအညီျဖင္သ
႔ ာ MSIL ကုိ အဆင္႔ဆင္႔ စက္နားလည္ေသာ Code ( Native Code ) အျဖစ္ ေျပာင္းလဲျပီးမွ သာ
စက္ေပၚတြင္ အလုပ္လုပ္နုိင္ျခင္း ျဖစ္သည္ ။ CLR သာ မရွိခဲ႔ပါလ်ွင္ စက္ေပၚတြင္ အလုပ္လုပ္နုိင္ေတာ႔မည္ မဟုတ္ပဲ
Compile time တြင္သာ ရပ္တန္႔သြားမည္ ျဖစ္သည္ ။ ဒီေနရာတြင္ မွတ္သားရန္ တစ္ခု ေျပာျပလုိပါသည္ ။ Programmer
မ်ားေျပာေျပာေနေသာ Error ဆုိသည္မွာ Compile Time တြင္ တက္ျခင္းျဖစ္ျပီး Exception ဆုိသည္မွာ CLR
တကယ္အလုပ္လုပ္ေနေသာ Run time တြင္ တက္လာျခင္း ျဖစ္သည္ ။
1.3 Asp.Net & C#.Net

Programmer ေတာ္ေတာ္မ်ားမ်ား ျငင္းခုန္ေလ႔ ရွိပါသည္ ။

- Asp.Net သည္ Programming Language မဟုတ္ပါ ။


- Asp.Net သည္ Framework တစ္ခုသာ ျဖစ္သည္ ။ Microsoft ၏ Web Application မ်ားကုိ develop လုပ္ရန္
အတြက္ ဖန္တီးထားျခင္း ျဖစ္သည္ ။
- ASP သည္ Active Server Pages ကုိ ဆုိလုိသည္ ။
- ASP.NET သည္ server-side scripting မ်ား ေရးသားရန္ နည္းပညာ သစ္ တစ္ခုသာျဖစ္သည္ ။

- C# ၏ အသံထြက္မွာ "C sharp" တစ္ျဖစ္သည္ ။


- C# သည္ Programmer မ်ားအတြက္ Application မ်ားကုိ Microsoft ၏ .Net Framework ေပၚတြင္
လ်င္ျမန္စြာ အေကာင္အထည္ ေဖၚရန္ တီထင
ြ ္ထားေသာ Programming Language အသစ္တစ္ခု သာ
ျဖစ္သည္ ။

- C#.Net ဆုိသည္မွာ .Net framework ေပၚတြင္ Programming Language ျဖစ္သည္႔ C# ျဖင္႔


ေရးသားထားျခင္း ျဖစ္သည္ ဟု ဆုိလုိသည္ ။

1.4 Asp.Net Versions မ်ားအေၾကာင္း

2009 ခုနွစ္ အထိ ထြက္ခဲ႔ေသာ Asp.Net Versions မ်ားကုိ ေဖၚျပေပးထားပါတယ္ ။

2002 2003 2005 2006 2009

Visual Studio VS.Net 2002 VS.Net 2003 VS.Net 2005 VS.Net 2005 VS.Net 2008

Languages C# v1.0 C# v1.1 C# v2.0 As before C# v3.0

VB.Net ( v7.0) VB.Net ( v7.1) VB2005 ( v8.0) VB9

Framework Netfx v1.0 Netfx v1.1 Netfx v2.0 Netfx v3.0 Netfx v3.5

Engine ( CLR ) CLR v1.0 CLR v1.1 CLR v2.0 Same version Same version
1.5 Client Server Architecture

Client ေခၚ Browser သည္ server ထံမွ web page မ်ားကုိ requests ( ေတာင္းခံရန္ ) လုပ္ရန္ တာ၀န္ယူသည္ ။
Server သည္ Browser မွ ေတာင္းခံလာေသာ web page မ်ားကုိ response ( ေပးပုရ
ိ႔ န္ ) လုပ္ရန္ တာ၀န္ယူရသည္ ။

Browsers အမ်ိဳးအစား အခ်ိဳ႔မွာ Mozila Firefox , IE ( Internet Explorer ) , Flock စသည္တုိ႔ ျဖစ္သည္ ။
Server အမ်ိဳးအစား မွာ Microsoft မွ ထုတ္လုပ္ထားေသာ IIS ( Internet Information Service ) ျဖစ္သည္ ။

ထိုသို႔ Client နွင္႔ Server တုိ႔ တစ္ခု နွင္႔ တစ္ခအ


ု ၾကားတြင္ web page မ်ားကုိ ေတာင္းခံျခင္း ၊ ေပးပုိ႔ျခင္း ျပဳလုပ္ရာတြင္
http ( hyper text transfer protocol ) ( Link ပါေသာ စာသားမ်ားကုိ သယ္ေဆာင္ေပးနုိင္ေသာ protocol ) ကုိ
အသံုးျပဳသည္ ။

1.6 Type of Applications create with Asp.Net

Asp.Net ျဖင္႔ Develop လုပ္နိင္ေသာ Applications ၅ မ်ိဳး ရွိပါတယ္ ။ အဲဒါေတြကေတာ႔

Window Application
Web Application
Web Service
Console Application
Mobile Application စသည္ တုိ႔ျဖစ္သည္ ။
Asp.Net Application မွာ ရွိတဲ႔ Events ေတြနဲ႔ Asp.Net Page တစ္ခုရဲ႔ ဦးစားေပး Events ေတြကုိ အခုလိုပဲ
တြဲမွတ္ထားပါ ။

1.7 Event Flows of Asp.net Application


Asp.Net Application မွာ ရွိတဲ႔ Events ေတြက အေပၚကေနေအာက္ ဒီလုိ ဦးစားေပးသြားပါတယ္ ။

• Application Level Events : (Global.asax)


• Page_Init : page and controls are initialized
• Page_Load : all the controls and page are loaded
• Change events : for controls are processed
• Click events : for controls are processed
• Page_PreRender : page is about to render
• Page_Unload : page is unloaded from memory ( Page Dead )

1.8 Event Flows of Asp.net Page


Asp.Net Page တစ္ခု မွာ ရွိတဲ႔ Events ေတြကေတာ႔ အေပၚကေနေအာက္ ဒီလုိ ဦးစားေပးသြားပါတယ္ ။

• Pre_init ( Initialize မလုပ္ခင္ အခ်ိန္ )


• Init ( Page ကုိ Initialize လုပ္ေနစဥ္ အခ်ိန္ )
• InitComplete ( Page ကုိ Initialize လုပ္ျပီးခ်ိန္ )
• Pre_Load ( Page ကုိ Load မလုပ္ခင္ အခ်ိန္ )
• Load (Page ကုိ Load လုပ္ေနေသာ အခ်ိန္ )
• LoadComplete ( Page ကုိ Load လုပ္ျပီးေသာ အခ်ိန္ )
• PreRender ( Page ကုိ processing မလုပ္ခင္အခ်ိန္ )
• RenderComplete ( Page ကုိ processing လုပ္ျပီးေသာ အခ်ိန္ )
• Unload ( Page ကုိ Server ေပၚမွ ျဖဳတ္ခ်လုိက္ေသာ အခ်ိန္ )
1.9 Asp.Net File Types

Asp.Net မွာ File Types မ်ားစြာ ရွိတဲ႔ အထဲကမွ မသိမျဖစ္ သိရမယ္႔ File အမ်ိဳးအစားမ်ားကုိ သာ ေဖၚျပ
ေပးထား ပါတယ္ ။

• .aspx
.aspx သည္ Web page ၏ Design ပုိင္းကုိ ရည္ညြွန္းသည္ ။

• .cs
.cs သည္ code-behind module ဟု ေခၚဆုိေလ႔ရွိျပီး Design ၏ ေနာက္တင
ြ ္ ကပ္ပါလာေသာ
မိမိေရးမည္႔ C# Language ကုိ ရည္ညြွန္းသည္႔ File extension တစ္မ်ိဳးျဖစ္သည္ ။
ဥပမာ ။ ။ C# Language ကုိ ယူအသံုးျပဳထားသျဖင္႔ ( pagename.aspx.cs ) ျဖစ္ေနေသာ္လည္း
VB Language ကုိ ယူ အသံုးျပဳထားပါက ( pagename.aspx.vb ) ျဖစ္သြားမည္ ျဖစ္သည္ ။

• .ascx
User controls ေရးသားရာတြင္ ေတြ႔ျမင္ရမည္႔ File extension တစ္ခု ျဖစ္သည္ ။

• .asmx
Web services ေရးသားရာတြင္ ေတြ႔ျမင္ရမည္႔ File extension အမ်ိဳးအစားတစ္ခု ျဖစ္သည္ ။

• .resx
Resources မ်ား ေရးသားရာတြင္ ေတြ႔ျမင္ရမည္႔ File extension တစ္ခု ျဖစ္သည္ ။ နုိင္ငံတကာ နွင္႔
သက္ဆုိင္ေသာ Application မ်ားကုိ Develop လုပ္ရာတြင္ Resource File မ်ားကုိ ထည္႔သင
ြ ္းေရးသားရသည္ ။
Global resource နွင္႔ Local Resource ဆုိကာ Resource နွစ္မ်ိဳး ရွိသည္ ။

• Global.asax
Application နွင္႔ Session တုိ႔ ၏ အစ နွင္႔ အဆံုး စသည္ တုိ႔ကုိ ထိန္းခ်ဳပ္ရန္ အသံုးျပဳသည္ ။

• Web.config
Application တစ္ခုလံုး၏ အျပင္အဆင္ အားလံုးကုိ Web.config တြင္ သတ္မွတ္ ေရးသားနိုင္သည္ ။
Database နွင္႔ ခ်ိတ္ဆက္ျခင္း မ်ိဳး ကုိလည္း web.config တြင္ ထည္႔သင
ြ ္း ေရးသားနုိင္သည္ ။

CHAPTER 2

2.1 Master Page


Master Page ကုိ Web Pages မ်ား ၏ ေနာက္တင
ြ ္ တူညီေသာ ေခါင္းစဥ္ ၊ တူညီေသာ Design ၊ တူညီေသာ
Menu မ်ား ၏ အသြင္အျပင္ အျဖစ္ ေပၚေစလုိေသာ အခါမ်ိဳးတြင္ တြင္ အသံုးျပဳသည္ ။ Master Page တြင္ ပါ၀င္ေသာ
တစ္ခုတည္းေသာ Control မွာ ContentPlaceHolder control ျဖစ္သည္ ။ Master Page တစ္ခုကို Web Pages
မ်ားစြာနွင္႔ ခ်ိတ္ဆက္ အသံုးျပဳနုိင္သည္ ။
2.2 Content Page
Content Page ဆုိသည္မွာ Master Page နွင္႔ ခ်ိတ္ဆက္ထားေသာ Web Page မ်ား ဘက္မွ အျမင္ျဖစ္သည္ ။
Content Page ဘက္မွ Master Page ၏ Design ကုိ ျပင္ရန္ မျဖစ္နုိင္ပါ ။

2.3 Web Server Controls


Web Server Controls ကုိ ေလ႔လာရာတြင္ လြယ္ကူေစရန္ ေအာက္တင
ြ ္ အုပ္စုခြဲကာ ေဖၚျပေပးထားပါတယ္ ။
Web Server control တစ္ခုကို အသံုးျပဳတုိင္း မျဖစ္မေန ပါရမည္႔ အခ်က္ ၂ ခ်က္မွာ -
“ ID “ နွင္႔ runat = “server” ဟူေသာ အခ်က္ နွစ္ခု ပင္ ျဖစ္သည္ ။

Function Control Name ID

စာ မ်ား ေဖၚျပရန္ Label lbl

စာ မ်ား ျပင္ရန္ TextBox txt

List တစ္ခုမွ ေရြးခ်ယ္ရန္ DropDownList ddl

ListBox lst

ပံုမ်ား ျပရန္ Image img

Adrotator adr

တန္ဖုိး တစ္ခုကုိ ေရြးခ်ယ္ရန္ CheckBox chk

Radio Button rbut

ေန႔ရက္ အခ်ိန္မ်ား ေဖၚျပရန္ Calendar cld

Command ေပး ခုိင္းေစရန္ Button but

LinkButton lnkbut

ImageButton imgbut

အေၾကာင္းအရာ တစ္ခု ႏွင္႔ ခ်ိတ္ရန္ HyperLink hylnk

အုပ္စု ဖြဲ႔ထားေသာ Controls မ်ား CheckBoxList chklst

Panel pnl

RadioButtonList rbutlst
ဥပမာ ။ ။
User Name ကုိ ရုိက္ထည္႔ရန္ အသံုးျပဳေသာ TextBox Control အတြက္ ေအာက္တင
ြ ္ ေဖၚျပထားသည္႔ အတုိင္း
သံုးရမည္ ျဖစ္သည္ ။
<asp : TextBox ID=”txtUserName” runat=”server” ></asp:TextBox>

DropDownList Control ကုိ အသံုးျပဳပါကလည္း ေအာက္တြင္ ေဖၚျပထားသည္႔ အတုိင္း သံုးရန္


<asp:DropDownList ID=”ddlUser” runat=”server “ > < /asp:DropDownList >

2.2 Asp.net Special Folders


Asp.Net ရဲ႔ web site ထဲမွာ Special Folders ေတြကုိ အခုလုိပဲ သတ္မွတ္ထားပါတယ္ ။
1 . App_Code
2 . App_Theme
3 . App_Data
4 . App_GlobalResources
5 . App_LocalResources
6 . App_WebReferences
7 . App_Browser
8 . Bin စသည္တုိ႔ ျဖစ္ပါတယ္ ။

2.3 Data Bound Controls


Data Bound Controls ေတြ အသံုးျပဳခ်င္ရင္ DataSource နဲ႔ DataBind( ) တုိ႔ မျဖစ္မေန ပါရမွာ ျဖစ္ပါတယ္ ။
Data Bound Controls အေရအတြက္ အားလံုး ၁၂ မ်ိဳး ရွိပါတယ္ ။
1. GridView
2. TreeView
3. DropDownList
4. BulletedList
5. DetailsView
6. CheckBoxList
7. RadioButtonList
8. ListBox
9. DataList
10. AdRotator
11. Menu
12. Repeater စသည္ တုိ႔ ျဖစ္ပါတယ္ ။
2.4 Tracing Key
Trace လုိက္ရာတြင္ အသံုးျပဳေသာ Key မ်ားကုိ စုစည္း ေဖၚျပေပးထားပါသည္ ။

Command (Hot Key) Description

F9 Trace လုိက္လုိေသာ ေနရာတြင္ Break Point ေထာက္ထားရန္ F9 ကုိ အသံုးျပဳသည္ ။

Step Into (F11) Trace လုိက္ေသာအခါတြင္ တစ္ေၾကာင္းခ်င္း၀င္ အလုပ္လုပ္ပံုကုိ ၾကည္႔ရန္ သံုးသည္ ။

Step Over (F10) Trace လုိက္ေသာအခါတြင္တစ္ေၾကာင္းခ်င္းလုိက္ခ်င္းမ်ိဳးမဟုတ္ပဲ မွန္ေသာ အဆင္႔မ်ား


ကုိ ေက်ာ္ထားခဲ႔ျပီး အလုပ္လုပ္ပံုကုိ ၾကည္႔ရန္ သံုးသည္ ။

Continue (F5) Trace လုိက္ေသာအခါတြင္ Brake Point ေနရာသုိ႔ ေရာက္ရန္ F5 ကုိ နွိပ္ပါ ။

Delete All Break Points Application တစ္ခုလံုး အတြင္းရွိ Break Points အားလံုး ျဖတ္လုိလွ်င္သံုးသည္ ။

(Ctrl+Shift+F9)

CHAPTER 3

3.1 Data Types


ေအာက္တင
ြ ္ ေဖၚျပထားေသာTable အတြင္းရွိ အ၀ါေရာင္ Data Types မ်ားကုိ မွတ္သားထားရန္ လုိအပ္သည္ ။

Data Type Long Form Storage Size Range

Int System.Int32 4 bytes –2147483648 to 2147483647

Long System.Int64 8 bytes –9223372036854775808 to


9223372036854775807

Byte System.Byte 1 byte 0 to 255

Float System.Single 4 bytes –1.5x10-45 to 3.4 x x1038

Double System.Double 8 bytes –5.0x10-324 to 1.7x10308

Decimal System.Decimal 12 bytes 1.0x10-28 to 7.9x1028

Char System.Char 2 bytes Unicode character

Boolean System.Boolean 1 byte True or false

String System.String 2 bytes * char count Unicode characters


3.2 Variable Declaration and Assign

MyVariable ဆုိေသာ string Data Type ကုိ အရင္ေၾကျငာျပီးမွ “Hello World” ဆိုေသာ string တစ္ေၾကာင္းကုိ
MyVariable ထဲသုိ႔ ထည္႔ပံုွ
string MyVariable;
MyVariable = "Hello World!";

MyVariable ဆုိေသာ string Data Type ေၾကျငာျပီးေနာက္ “Hello World” ဆိုေသာ string တစ္ေၾကာင္းကုိ
MyVariable ထဲသုိ႔ တုိက္ရုိက္ ထည္႔ပံုွ
string MyVariable = "Hello World!";

Data Type တစ္ခု၏ေနာက္တင


ြ ္ Variable မ်ားစြာ ေၾကျငာ အသံုးျပဳနုိင္သည္ ။
int A, B, C ;

Data Type တစ္ခု၏ေနာက္တင


ြ ္Variable မ်ားစြာ ေၾကျငာနိုင္ရံုသာမက တန္ဖိုးကုိပါ တုိက္ရုိက္ ထည္႔သင
ြ ္းနုိင္သည္။
int A = 9, B = 7;

3.3 Constructor
Function Name တစ္ခုသည္ Class Name နွင္႔ တူညီေနျပီး return type မပါ၀င္လ်ွင္ Constructor အျဖစ္
သတ္မွတ္ နုိင္သည္ ။ Constructor နွစ္မ်ိဳး ရိွသည္ ။
1. Default Constructor
2. Argument Constructor

Default Constructor သည္ argument ပါ၀င္ေလ႔မရွိ ။


public class Sample
{
public Sample()
{

}
}

Argument Constructor သည္ Default Constructor နွင္႔ သေဘာတူေသာ္လည္း Argument Constructor


ထဲတင
ြ ္ argument မ်ား ပါ၀င္လာေလ႔ ရွိသည္ ။
public class Sample
{
public Sample(argument)
{

}
}
3.4 Method and Parameters

Parameters မပါေသာ Method


protected void Page_Load(object sender,EventArgs e)

{
SetPageTitle();
}

void SetPageTitle()
{
this.Page.Title= “ Test Page”;
}

Parameters ပါေသာ Method


private int AddNumbers ( int A , int B)
{

return A + B ;
}

3.5 Operators
သိထားရမည္႔ Operators မ်ား ျဖစ္သည္ ။
Primary x++ x-- x++ အလုပ္လုပ္ျပီးလ်ွင္ x တန္ဖိုး ကုိ ၁ တုိးမည္ ။
x-- အလုပ္လုပ္ျပီးလ်ွင္ x တန္ဖုိး ကုိ ၁ ေလွ်ာ႔မည္ ။
Unary ++x --x ++ x အလုပ္မလုပ္ခင္ x တန္ဖိုး ကုိ ၁ တုိးမည္ ။
--x အလုပ္မလုပ္ခင္ x တန္ဖိုး ကုိ ၁ ေလ်ွာ႔ မည္ ။
Multiplicative * / % * အေျမွာက္ / အစား % အၾကြင္းရလာဒ္ တြက္ရန္

Additive + - + အေပါင္း - အနွုတ္

Shift << >> << ဘယ္ေရြွ႔ >> ညာေရြွ႔

Relational < > <= >= < ငယ္ > ၾကီး <= ငယ္လွ်င္ညီလ်ွင္ >= ၾကီးလ်ွင္ညီလ်ွင္

Equality = = != = = ( တူလွ်င္ ) != ( မတူလွ်င္)


Conditional AND && အေရွ႔ နွင္႔ အေနာက္ အေျခအေန နွစ္ခုလံုး အတြက္
Conditional OR || အေရွ႔ သုိ႔မဟုတ္ အေနာက္ အေျခအေန တစ္ခုခု အတြက္
Conditional c?x:y c မွန္လွ်င္ x အလုပ္ကုိလုပ္ျပီး မွားလ်ွင္ y အလုပ္ကိုလုပ္သည္ ။
Assignment = += -= *= /= တုိက္ရုိက္ Assign လုပ္လိုလွ်င္ သံုးသည္ ။
3.6 Function and Variable Scope

Declared Meaning

Public မည္သည္႔ Class က မဆုိ ေခၚယူ အသံုးျပဳနုိင္သည္ ။

Protected သက္ဆုိင္ရာ Class တစ္ခုမွ Inherit လုပ္ထားေသာ Class က သာ ေခၚယူ အသံုးျပဳနုိင္သည္ ။

Private Class တစ္ခု အတြင္းတြင္သာ အသံုးျပဳနုိင္သည္ ။

3.7 C# Data Type Convertions

Data Type တစ္ခု မွ တစ္ခု သုိ႔ ေျပာင္းလဲရန္ နည္းလမ္း ( ၃ ) မ်ိဳး ရွိပါသည္ ။


အ၀ါေရာင္ ျပထားေသာ ေျပာင္းပံုေျပာင္းနည္း နည္းလမ္းမ်ား ကုိ အသံုးျပဳနုိင္သည္ ။

int A = 10;
double dblA;
dblA = (double)A;

int intA = 10;


string strA;
strA = Convert.ToString(intA);
intA = Convert.ToInt32(strA);

int intA;
string strA = "10";
// Convert the string "10" to the numeric value 10.
intA = Int32.Parse( strA ) ;

3.8 Statements
3.9 Loops
Statements နွင္႔ Loops မ်ား အေၾကာင္းကုိ အရင္ ေရးသားထားေသာ “C#
C# Programming Fundamentals”
Fundamentals
ျမန္မာျပန္ EBook တြင္ ျပန္လည္ ေလ႔လာ နုိင္ပါသည္ ။
CHAPTER 4

4.1 Validators
1. Require Field Validator
2. Range Validator
3. Regular Expression Validator
4. Compare Validator
5. Custom Validator
6. Validation Summary

1.Require Field Validator


User တစ္ေယာက္အား Control ထဲသုိ႔ Data မထည္႔မိေသာအခါ သတိေပးရန္အတြက္ အသံုးျပဳသည္ ။
Require Field Validator Control ၏ အသံုးမ်ားေသာ Properties မ်ား
- ControlToValidate
- ErrorMessage
- Text

2.Range Validator
User တစ္ေယာက္အား သတ္မွတ္ထားေသာ အတုိင္းအတာအတြင္းတြင္သာ Data ထည္႔ရန္ သတိေပးလုိေသာ အခါ
အသံုးျပဳသည္ ။
လူတစ္ေယာက္ အသက္သည္ 1 to 110 တြင္းသာ ရွိရမည္ ။
Range Validator ၏ အသံုးမ်ားေသာ Properties မ်ား
- ControlToValidate
- ErrorMessage
- Minimum
- Maximum
- Type
- Text
- Operator

3.Regular Expression Validator


စနစ္တက် သတ္မွတ္ထားျပီးေသာ Email ကဲ႔သုိ႔ ပံုစံမ်ား စစ္ရန္ အတြက္ အသံုးျပဳသည္ ။
Email လိပ္စာ တြင္ “@” Sign မျဖစ္မေန ပါ၀င္ရမည္ ။ ( stringlive@gmail.com )
Regular Expression Validator ၏ အသံုးမ်ားေသာ Properties မ်ား
- ControlToValidate
- ErrorMessage
- ValidationExpression
- Text
4.Compare Validator
တန္ဖုိး တစ္ခု နွင္႔ တစ္ခု ၊ Control တစ္ခုနွင္႔တစ္ခု နွိုင္းယွဥ္ရာတြင္ အသံုးျပဳသည္ ။
Password နွင္႔ Confirm Password တုိ႔ကုိ စစ္ရာတြင္ အသံုးျပဳနုိင္သည္ ။
Compare Validator ၏ အသံုးမ်ားေသာ Properties မ်ား
- ControlToValidate
- ControlToCompare
- ErrorMessage
- Text

5.Custom Validator
မိမိကုိယ္ပုိင္ေရးသားရျခင္းျဖစ္ျပီး ရွိျပီးသား Validator Control မ်ားနွင္႔ မလံုေလာက္ေသာအခါ အသံုးျပဳသည္ ။
Custom Validator ၏ အသံုးမ်ားေသာ Properties မ်ား
- ControlToValidate
- ErrorMessage
- ClientValidationFunction
- Text
Event
- ServerValidate

6.Validation Summary
Validation စစ္ရာမွ ရရွိလာေသာ ErrorMessage မ်ားကုိ တစ္ေနရာတည္းတြင္ စုစည္းေဖၚျပရန္ အတြက္ အသံုးျပဳသည္ ။

4.2 Web User Control, Custom Control, Composite Control


Web User Control
-------------------------
1 . WebSite ထဲတင
ြ ္သာ ေရးသားရသည္ ။
2 . ascx ဖုိင္ အမ်ိဳးအစားကုိ ယူ ေရးရသည္ ။
3 . No DLL ( DLL = Dynamic Link Library မထြက္ပါ )
4 . အသံုးျပဳလုိေသာ Web Page ေပၚသုိ႔ User Control ကုိ တုိက္ရုိက္ ဆြဲတင္ အသံုးျပဳနိုင္သည္ ။

Custom Controls
----------------------
1 . Project ထဲတင
ြ ္ ရွိေသာ Class Library တြင္ ၀င္ေရးရသည္ ။
2 . ဖုိင္ အမ်ိဳးအစားသည္ .cs ဖုိင္ အမ်ိဳးအစား ျဖစ္သည္ ။
3 . DLL ဖုိင္ ထြက္သည္ ။ ထုိ႔ေၾကာင္႔ Visual Studio 2005/2008 တုိ႔၏ ToolBox တြင္ ထည္႔သင
ြ ္း အသံုးျပဳနုိင္သည္ ။
4 . အသံုးျပဳပံုမွာ Asp.Net Control မ်ား ကဲ႔သုိ႔ပင္ ျဖစ္သည္ ။
Composite Controls
--------------------------
Custom Control ကဲ႔သုိ႔ျဖစ္ျပီး Asp.net Controls မ်ား တစ္ခုထက္ပုိ ေပါင္းစပ္ေရးသားထားေသာ Control ျဖစ္သည္ ။
1 . Project ထဲတင
ြ ရ
္ ွိေသာ Class Library တြင္ ၀င္ေရးရသည္ ။
2 . ဖုိင္ အမ်ိဳးအစားသည္ .cs ဖုိင္ အမ်ိဳးအစား ျဖစ္သည္ ။
3 . DLL ဖုိင္ ထြက္သည္ ။ ထုိ႔ေၾကာင္႔ Visual Studio 2005/2008 တုိ႔၏ ToolBox တြင္ ထည္႔သင
ြ ္း အသံုးျပဳနုိင္သည္ ။
4 . အသံုးျပဳပံုမွာ Asp.Net Control မ်ား ကဲ႔သုိ႔ပင္ ျဖစ္သည္ ။

CHAPTER 5
5.1 State Management Technologies

Client Side State Management တြင္ Cross Page လည္း ပါ၀င္သည္ ။


CHAPTER 6

6.1 ADO.Net

ADO.NET သည္ Data access နည္းပညာတစ္ခု ျဖစ္ျပီး Connected Approach နွင္႔ Disconnected Approach
ဆုိေသာ နည္းလမ္း ႏွစ္မ်ိဳး ရွိပါတယ္ ။

Connected Approach တြင္ ပါ၀င္ေသာ Object ေလးမ်ိဳးမွာ


- Connection Database နွင္႔ ခ်ိတ္ဆက္ရန္
- Command Database ကုိ Connection Object နွင္႔ တြဲကာ ခုိင္းေစရန္
Command ကုိ ေလးမ်ိဳး ထပ္ခြဲ နုိင္သည္ ။

ExecuteNonQuery( )
Return Value မရွိ ။
INSERT, UPDATE, or DELETE တို႔အတြက္သံုးသည္ ။

ExecuteReader( )
Database Query တစ္ခုမွ Result Set ကုိ Return ျပန္ေပးသည္ ။
DataReader object သေဘာတရားပင္ ျဖစ္သည္ ။
SELECT အတြက္သံုးသည္ ။

ExecuteXMLReader( )
XML File မ်ားကုိ ဖတ္ရန္ အသံုးျပဳသည္ ။

ExecuteScalar( )
Database query တစ္ခု မွွ Return ျပန္လာေသာ Single value တစ္ခုကို
လက္ခံရန္ အသံုးျပဳသည္ ။

- DataReader Data Reader သည္ Forward-Only , Read-Only ျဖစ္သည္ ။


- DataAdapter Connected Approach ထဲတင
ြ ္ ထည္႔သင
ြ ္း ေရးသားထားေသာ္လည္း
တကယ္တမ္း DataAdapter သည္ Disconnected Approach ထဲတင
ြ ္
ရွိေသာ DataSet နွင္႔ သာ ခ်ိတ္ဆက္ အလုပ္လုပ္ေပးသည္ ။
DataAdapter ထဲတင
ြ ္ပါ၀င္ေသာ Fill ( ) Method ျဖင္႔ DataSet ထဲသုိ႔
Database မွ Data မ်ား ထည္႔သင
ြ ္း နုိင္ရန္ ကူညီေပးသည္ ။

Disconnected Approach ( DataSet )


DataSet ဆုိသည္မွာ DataTables စုစည္းထားသည္႔ သေဘာျဖစ္သည္ ။

You might also like