Vous êtes sur la page 1sur 547

WWW.IRANMEET.

COM

Programming

ASP.NET
ASP.NET

m.bashiry@gmail.com
Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

:
.

www.iranasp.net

:
:

m.bashiry@gmail.com
M_bashiry@walla.com
Mohamad_bashiry@yahoo.com

1384/3/17
3

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com


9 .................................................................................................................................... ASP.NET
10 ....................................................................................................................................... Microsoft.NET
ASP.NET 13..................................................................................................................................................................
ASP.NET 17 ................................................................................................................................................
19 ..................................................................................................................................... ASP.NET
22 ............................................................................................................... ASP.NET
25 .....................................................................................................................................................
30 .........................................................................................................................................................................
33...................................................................................................................................... .NET
35 ................................................................................................................................................................................. CLR
41 ............................................................................................................................ Client server
49................................................................................................................................. ASP.NET
52 .........................................................................................................................
ASP.NET 61......................................................................................................
Cashing 73 ................................................................................................................................................. ASP.NET
78 ........................................................................................................... ASP.NET
82.............................................................................................................................................. ASP.NET
84 ..................................................................................................................................................... ASP.NET
Smart Navigation88......................................................................................................................................
91...................................................................................................................................................... ASP.NET
4

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Codebehind94.......................................................................................................................................................
Namespace98.......................................................................................................................................................
Upload 106.............................................................................................................. ASP.NET
Cashing 111 ................................................................................................................................................. ASP.NET
117 .....................................................................................................................................
ASP.NET 121 ........................................................................................................................
127.................................................................................................................. ASP.NET
144 ............................................................................................................................. .NET Framework 1.1
10 148..........................................................................Visual Studio .NET 2003
Thread 151 ...............................................................................................................................................ASP.NET
163 ............................................................................................................................................ ASP.NET
XML 170 ............................................................................................................................ ASP.NET
XML 173..............................................................................................................................................
176...........................................................................................................................................................ASP.NET
180 ...............................................................................................................ASP.NET
4 )2003 183 ......................................... (...
197 ................................................................................................................................... ASP.NET Whidbey
Session State 202 ................................................................................................................................ASP.NET
206...................................................................................................................................... ASP.NET
209 ................................................................................................................ ASP.NET
Web.config 214 ................................................................................................................................
5

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

IrMail ) ASP.NET ( 221 .....................................................................


IrMail ) ASP.NET (228 .....................................................................
235 ......................................................... ASP.NET
248 ................................................................................................................................................ASP.NET
XML ) ASP.NET ( 258......................................................................
XML ) ASP.NET ( 264......................................................................
Setup .NET Crystal Report 276 ................
278.................................................................................................................................................................. .NET
Generic Principle280 ......................................... FormsAuthentication
285 ................................................................................................................................ ASP.NET
RSS 302 ........................................................................................................................
ASP.NET 1.x ASP.NET 2.0 311 .................................................................................
ASP.NET 1.x ASP.NET 2.0 328 ................................................................................
347 ......................................................................................................................................... ASP.NET
ASP.NET 354 ........................................................................................................................
ASP.NET 364.......................................................................................................................
373 .............................................................................................................................................................
) (Whios 379 .................................................................................................... ASP.NET
385 .....................................................................................................................
393 ......................................................................................................................................... ASP.NET
400.......................................................................................................................................................... ASP.NET
6

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

404 ..................................................................................................................................................
405 ....................................................................................................................................................................... HTML
408 ............................................................................................................................................... ASP.NET
412.............................................................................................................. ASP.NET
Label 417 ........................................................................................................................................................
ListBox 420.................................................................................................................. ArrayList
Hyperlink 422 .................................................................................................................................................
424..................................................................................................................................................................
429 ....................................................................................................... ASP.NET
432 ....................................................................................................................................................
435 ...........................................................................................................................................
442 ..............................................................................................................................................................
446 ............................................................................................................................................. DataGrid
450 ............................................................................................................................................AdRotator
453 .............................................................................................................................ASP.NET
ViewState ) ( 457 ...................................................................................................
ViewState ) ( 459..................................................................................................
464 ........................................................................................................... ListBox
ListBox 471.............................................................................................................. ASP.NET
JavaScript 479 ........................................................................................................................................... ASP.NET
488 ................................................................................................................................................. DataList
7

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

490........................................................................................... ASP.NET
497.............................................................................................................................................. DataGrid
501 ......................................................................................................................... DataGrid
DataSet 508......................................................................................
- 514 ....................................................................................................................................................
- 519 ...................................................................................................................................................
:ASP.NET 2.0 Master Page 526 .........................................
:ASP.NET 2.0 Master Page 535 ................
UserControl 540......................................................................................
544 .................................................................................................................................................................................

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

ASP.NET

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Microsoft.NET

.NET
NET .NET .
.NET . .NET .NET :
.
.NET
.NET 3400 .
.
XML .
.NET
.NET
namespace .
System.IO .
. File System.IO
System.IO.File . ASP.NET
. System.Web . HTML

1 iranasp.net
10

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

System.Web.UI.HTMLControls Web System.Web.UI.WebControls


.
.NET
.NET ) (Assemblies .
.
. System.IO
Mscorlib.dll . Mscorlib.dll
.NET .
.
.

.NET
.NET (The .NET
)Common Language Runtime - CLR . ASP.NET

.
) (Microsoft Intermediate Language

11

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

MSIL IL . MSIL .
. ASP.NET
MSIL . MSIL JIT
. ASP.NET MSIL
.
.
ASP.NET C#
C++ .
MSIL .
.NET
. C#
.

12

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

ASP.NET

m.bashiry@gmail.com

ASP.NET ASP
Active Server Pages ASP .
.
ASP.NET
.
. ASP.NET .
ASP.NET .
ASP.NET
.
ASP.NET .
ASP.NET .
ASP.NET .
DataGrid .
ASP.NET .NET.

1 iranasp.net
13

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

.NET 4500 ASP.NET .


.
.
ASP.NET ASP
ASP.NET ASP ASP .
. ASP VBScript JScript
ASP.NET Visual Basic ( C#-
( . ASP (Request, Response, Application
)Session, Server ASP.NET 4500
.NET . ASP.NET ASP
. ASP.NET
HTML ASP .
ASP.NET
ASP.NET .NET .
Visual Basic.NET C# JScript.NET .
ASP.NET C++
ASP.NET .
ASP.NET .
PERL COBOL ASP.NET .
14

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET

TextBox ListBox . ASP.NET
. ASP.NET :
ListBox RadioButton TextBoxButton.
.
.
.
Visual Studio.NET
. Notepad
.
ASP.NET
ASP.NET ASP.NET .NET
.
.NET Framework

15

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

msdn .microsoft.com/downloads/default.asp@url=_2fcode_2fsample.asp@url=_2f
msdn -files_2f027_2f000_2f976_2fmsdncompositedoc.xml
Windows ( Professional Server ) Windows 2000 ASP.NET
. XP

16

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET

ASP.NET
ASP.NET : .
.
HTML .
ASP.NET .
.
>"<Script Runat="Server
Sub Page_Load
)(myLabel.Text = DateTime.Now
End Sub
></Script
><html
><head><title>Simple.aspx</title></head
><body
<asp:Label
"ID="myLabel
>Runat="Server" /
></body
></html

1 iranasp.net
17

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com


1 >" <Script Runat="Server
> <Script/ . Page-Load
. Text Label
.

.
HTML . Label
ASP.NET HTML .
Label :
><asp:Label ID="myLabel" Runat="Server"/
HTML .

18

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET

ASP.NET Init
Load...
ASP.NET :
:Init .
:Load .
: PreRender .
: Unload .
: Disposed .
.
Load :
>"<Script Runat="Server
Sub Page_Load
' Place any code that you want to execute here
End Sub
></Script
1 iranasp.net
19

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Page_Load Load
. Init Load PreRender Unload Disposed
Page_Init Page_Load Page_PreRender Page_Unload Page_Disposed
.
Load .
.
DataGrid .
Load PreRender Load
. .
Page_Load Button_Click Page_PreRender .
Page_Load Button_Click Page_PreRender .
>"<Script Runat="Server
Sub Page_Load
) "Response.Write( "<li> Page_Load
End Sub
) Sub Button_Click( s As Object, e As EventArgs
) "Response.Write( "<li> Button_Click
End Sub

20

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

Sub Page_PreRender
Response.Write( "<li> Page_PreRender" )
End Sub
</Script>
<html>
<head><title>EventOrder.aspx</title></head>
<body>
<form runat="Server">
<asp:Button
Text="Click Here!"
OnClick="Button_Click"
Runat="Server" />
</form>
</body>
</html>

21

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET

ASP.NET .
www.iranasp.net/download/shahoo01.zip :

. ASP.NET .
1 .
><html><body
>You are using <% =Request.Browser.Type %
></body></html
IE 5 :
You are using IE5
Request.Browser.Type 1 .

HTTPBrowserCapabilities
Browser Request HTTPBrowserCapabilities
System.Web . ASP.NET
. Request
1
22

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

MSWC. BrowserCapabilities
ASP .
HTTPBrowserCapabilities :
:ActiveXControls .
:AOL AOL .
:Cookies
.
:Crawler .
:Browser .
:Frames Frame .
:MajorVersion IE5 5
.
:MinorVersion )( IE5.1 1.
.
:Type ..
:VBScript VBScript .
23

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

. :Version
.
<%@ page language="VB" %>
<%@ Import Namespace="System.Web" %>
<html>
<body>
<head><title>HTTPBrowserCapabilities Demo</title></head>
<%
Dim browserObj As HTTPBrowserCapabilities
browserObj = Request.Browser
%>
<font face="verdana, arial" size=2>
<p>Your browser supports ActiveX controls: <%=browserObj.ActiveXControls %>
</p>
<p>Your browser type: <%=browserObj.Type %> </p>
<p>Your browser version: <%=browserObj.Version%> </p>
... Add any other property that you would like to display
</font>
</body>
</html>

24

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

.

.
.
8
.
COM . 1970
Unix .
. -.NET

.NET .
Client .
NET .
. 1995 Client Server
. COM +COM
6 . 1999 50

1
25

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

.
.
ASP Active Server Page .
. 6 Internet
Application Web Class
.
DNA
Distributed interNet Application
n-tier COM . DNA .
Presentation tire .
Internet Browser Win 32 GUI .
Win32 GUI
DLL Hell .
... .
. Java Applet ActiveX
ActiveX
IE .
Middle tier .
.
26

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

DNA . COM
ADO ADSI .
.
Data tier .
SQL Server Oracle .
COM
DNA COM .
COM ) : NET .
(
:DLL Hell COM
. COM
GUID COM .
COM

.
.
: COM C++
COM .
27

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

DNA
- 1 Client

ASP . ASP
.
.
- 2
textbox . Win32 GUI
textbox .
ASP refresh . Request
Response ASP.
- 3 Event Handler
Win32 GUI Event .
ActiveX
95 .
API

28

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

API 1 .

. API
. 98 95 .

.
API . CE
.
Professional VB.NETWrox

29

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com



. 1998 6
.NET 2000 PDC
. % 80 .NET .
SOAP Simple Object Access Protocol .
Web Service .
.NET
: Win32 GUI
Win32 GUI .NET .
:
Win32 GUI.
: .NET
.

1
30

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

: .NET
++C . Cobol.NET Pascal.NET
. .
!
Platform : .NET
Unix Linux Mobile PDA .
.NET .
.
.NET
.NET Framework
.
. .NET NET Framework.
.
.NET .
www.geocities.com/hamedbanaei/netframe.htm
CLR .NET
NET Framework. CLR Common Language Runtime . CLR
MSIL Microsoft Intermediate
31

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Language . IL just-in-time
. .NET .
.NET IL IL NET
Framework. . just-in-time
IL . CLR
.NET object
object . CLR Garbage
Collection . CLR .
NET Framework.

ADO.NET ADO XML .NET
Threading . thread
ASP.NET Windows Forms
client
.
Professional VB.NETWrox

32

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

.NET

:
.
.NET Assemblies :
Modules . Types .NET (Deployment).
property
.

manifest XML HTML.
Manifest :
text .
....
.
Optional : RequiredDenied.
.

1
33

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

.

DLL ) EXE Windows PE (Portable Executable
Meta Data IL manifest . manifest
manifest manifest . CLR
IL install-time JIT
just-in-time method by method .
. JIT . Meta Data
IL.

Value Reference . method property field .
.
Professional VB.NETWrox

34

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

CLR

CLR

CLR Common Language Runtime NET platform. .
CLR runtime . 6
Runtime
. CLR runtime
.NET .

6 COM COM
. COM
ProgID . Word.Application
Word.Application.9. CLR GAC
Global Assemblies Cache . GAC . CLR
GAC :
:Side-by-side versioning
.

1
35

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

:Automatic QFE GAC


CLR .
CLR Major.Minor.Revision.Build . Major
Minor .


. .
. .NET
. NET Framework. .
xcopy !
.NET
.

CLR VB .
: Garbage Collection
Runtime Garbage Collection .
runtime 6 .
36

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

LOG Scripting.Stream
Scripting.FileSystemObject .
runtime . runtime
.
:Cyclical References
runtime VB
Cyclical Reference
. A reference B BA.
COM .
AddRef Release IUnKnown interface
.
COM Release .
runtime VB 6
runtime .
.
'Class : CCyclicalRef
Dim m_objRef as Object

37

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

)Public Sub Initialize(objRef as Object


Set m_objRef = objRef
End Sub
)(Private Sub Class_Terminate
)"Call Msgbox("Terminating.
Set m_objRef = Nothing
End Sub
CCyclicalRef Initialize
. .
Dim objA as New CCyclicalRef
Dim objB as New CCyclicalRef
)Call objA.Initialize(objB
)Call objB.Initialize(objA
Set objA = Nothing
Set objB = Nothing
CCyclicalRef objA objB
. Initialize
2 .
.

38

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

nothing . .
terminate .
Garbage Collector: CLR
Garbage Collector CLR VB 6 Runtime . CLR
GC nothing
GC .
COM GC
.
:Finalize
GC Object.Finilize .

. .NET nothing Dispose Close
.

virtual memory
heap . CLR Managed Heap
Heap CLR
.
39

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

.
Heap
. CLR heap
. .
www.geocities.com/hamedbanaei/memorialoc.htm
CLR B A C Heap . B
D
C . . CLR heap
.
CLR GC . GC B
heap heap .
Professional VB.NETWrox

40

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Client Server

Client/Server

80
Client/Server .
) (
Server Client )
(.
.
Client Server
.
. .
.
:
): Presentation ( )
( .
.

1
41

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Application : Business Logic



.
:Service
.
.
) ( Tires Client Server ) (
. .
One-Tire
.
Presentation . Application
Presentation Service .
.
.
One-tire

.
) (Peer to Peer ) ( File Server .
42

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Database Engine
.
. ) ) One Tire
.

.
Reza ) (
.
.
Database Engine
) ( Conflict
) .( Record Locking
Two Tire
One-tire .
One
Tire Database Engine .
.
) Application(Logic Database Service SQL . (
43

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

. SQL
) (
. Presentation
Busines Logic . ) (
.
.
.
DataBase Engines One-Tire
) Jet Engine ( Two Tire
Oracle , IBM DB2 , Sybase SQL Sever .
Three Tire
.
Business Logic .
Business Application Server
. Application Server DataBase Engine
. .
Application Server
.
Application Server ) .
44

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Application Server
Application Server
(. Application Server Database Server
.
Presentation
Application Server .
Amazon.com
.
Application Server . ) ) Three Tire

.
N Tire
. Three Tire N-
Tire . Application Server
.
. MiddleWare Business Logic
Application Server .
Bussines Logic Application Server

45

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com


.
.
) ( Application
.


.
Presentation
.
Application

.
Presentation
. .
Presentation .
Application
Presentation
Presentation .
Presentation . Logic
46

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Presentation
. Thin Client .
Logic Fat Client . Thin Client
.

Client Server
.
) ( .
Server Client .
One Tire Two-Tire Three Tire N-Tire
) ( Server
) (Client .

.
.
.
i
) (Reusable Code

47

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

. Three Tire
N-Tire .

48

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Email ASP.NET

Email ASP.NET .
www.iranasp.net/download/shahoo04.zip :
Email ASP.NET SmtpMail
System.Web.Mail Send .
Email Send MailMessage . MailMessage
System.Web.Email Email .
MailMessage CDONTS ) CDONTS
Email ASP (.
:
Body Priority Subject BodyFormat Bcc Cc From To.
Email MailMessage
:
- 1 MailMessage :
Dim ObjMM As New MailMessage
- 2 email :
1
49

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

ObjMM.To="someone@someaddress.com"
email: - 3
ObjMM.From="someoneelse@someotheraddress.com"
: Bcc Cc - 4
ObjMM.Cc="someone2@someaddress.com"
ObjMM.Bcc="someone3@someaddress.com"
: html text email BodyFormat - 5
Obj.MM.BodyFormat=MailFormat.Text
High Security Priority - 6
: Low Normal
ObjMM.Priority=MailPriority.Normal
: Subject - 7
ObjMM.Subject="Hello there"
:( ) Email Body - 8
ObjMM.Body = "This is body!"
: ASP.NET System.Web.Mail
50

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

><% @import NameSpace="System.Web.Mail" %


MailMessage Send SmtpMail
MailMessage :
)SmtpMail.Send(ObjMM
SmtpMail Email Smtp IIS
. Send SMTP Email .
SMTP ) ( SmtpServer
:
SmtpMail.SmtpServer= emailservername
SmtpServer ) (Default :
""=SmtpMail.SmtpServer
Email ...
html (Feedback).
www.iranasp.net/download/shahoo04.zip
.

51

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

.

:
.


)(
.
.
: .
.

.
.

. .
Program = Logic(Code) + Data
1
52

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com


.
:
MainFrame Architecture
: Host
. )(Logic
) (Data Host
) ( .
) (Host .
File Server Architecture
Server Client .
.
Server ) (File Server
Client . .
Client Server . )
(
. ) ( Client
.
Client Server Architecture
53

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

.
Server Client . ) (

.
.
.
.
Two Tire Architecture


) ( . DataBase
Engine
.
.
) (Tires.
Three Tire Architecture
) (
.

54

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com


.

.
: ) )

) ( . ) (

N-Tire .
.
)(

.
.
.
Component Object Model COM .
COM
) ( .

55

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

) (
.
COM
COM
. Object Linking & Embedding OLE 1991

. ) (Documents .

. OLE 2 1995
COM .
.
.
95 NT 1996
Distributed COM DCOM . 1997
+COM .
Three Tire

.

56

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Internet Explorer COM/DCOM/COM+ ActiveX .


) Java/J2EE NetScape ( CORBA .
CORBA 1992 Object Management Group OMG
. ) (2 1996 .
COM .

.
Tire
Tire Tire
Tire .
:
User Sevices
Business Services
Data Services
Three Tire Tire .
Tire Tire
Tire .
Tire Tire ) (
Tire . User Services
Data Services . .
57

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com



.

.
Three Tire :
Single Server
Business Server
Transaction Server
Web Server
Single Server
.
) (Data Services .
User Service
. Business Services

User
Services )
( . User Services
.
58

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

)Bussines Server (Application


Application Server .
.
User Service
Application.
Data service Data .
Application Server .
Application Data .
Transaction Server
Transaction .
. Transaction
Transaction .
.
.
Transaction ActiveX
.
Web Server
.

59

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

.
.
.

.

.

.
.
.

.

.
.
.

.

60

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET


ASP.NET
ASP.NET .
ASP . ASP
.
.
ASP.NET ASP
HTML .
ASP . ASP.NET
.
) (Static ) (Dynamic
ASP.NET .

.
""
Html Htm Html .
1
61

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

.
) (
.
.

- 1 Html Htm Html
.
- 2 .
.
- 3 Htm .
- 4 Html .
- 5 Html .



.
Html )
Html
!(.
62

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

.
Html
. Html
. )

!(.
Html .
.
. Html
. Html
. :
:
(Client Side Dynamic Web Page).
:
). ( Server Side Dynamic Web Page

.
.
IIS . Apache .
63

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET IIS . IIS


2000 XP . IIS 5.0 2000 IIS 5.1 XP
.
.
.
.
.

) (Plugin
. Html
. Html
. .
Client-Side :
- 1 Html
Htm .
- 2
.
- 3 ) (
64

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

.
- 4 Html
.
- 5 Html Html
.
- 6 Html .

. VBScript ActiveX

.
)(JavaScript
. Html
.
. LiveScript .
NetScape 2.0 . Sun
.
)
C ( .
65

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

. : )
( . .

:
. Jscript
IE 3.0 .
VBScript
IE 3.0 VBScript
.
.
) (Case Sensitive .
) (IE .
Plug-In .
VBScript .

. VBScript Script
Engine
. VB.NET VBScript .
ActiveX
66

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

++C
.
Timer Bar Chart .
> <Object .

. Plug-in
.

.

IE .
Java Applet
Platform .
. . ><Applet
.
) (JVM .
: > <Object <Applet>.
DownLoad
) (JVM .

67

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com


Download .
. Drop-Down Menu
.

Html
Html
.
: Server-Side
- 1 Html
.
- 2
.
- 3 .
- 4 Html .
- 5 .
- 6 Html .

68

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com


. Client-Side :
Html .

. ASP ASP.NET .

.
.
CGICommon Gateway Interface

. CGI .
ASP
. CGI )
(Perl . Perl C
C++ .
Platform .
ASPActive Server Page

69

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET ASP
.
VBScript . ASP
(ASP.dll).

.
.
ASP.NET .
JSPJava Server Page
Html Xml . ASP
) (IIS
. JSP ASP
. JSP Java2
JavaBeans Java2 Libraries .
ColdFusion
.
.
.
ColdFusion . IIS
70

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

. Html-Like
) ASP.NET ( .
!
PHP
Personal Home Page PHP Hypertext
Preprocessor .
ASP.NET Cross-Platform NT
. C Perl .
.
ASP.NET
ASP.NET
. ASP.NET (aspnetIsapi.dll).

. ASP.NET )
( :
ASP.NET Server Side
.

71

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP VBScript
) VBScript (. ASP.NET .
. Jscript.NET C# VB.NET
Python Perl ASP.NET .

72

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Caching ASP.NET

Caching ASP.NET
Caching -1 ASP
Caching ASP
.
Caching ASP
) (Client )
HTML (.
ASP
Caching
Caching .
Caching . ASP
. ASP.NET Caching
ASP ASP.NET .
- 2 Caching ASP.NET
ASP.NET ASP . :
><%@ OutputCache Duration = "..." VaryByParam = "..." %
1
73

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET )> (<%@ ... %


. Duration
VaryByParam .
-: Duration
Caching . .
Caching :
><%@ OutputCache Duration = "15" VaryByParam = "none" %
ASP.NET Label Button .
Label . )
21:30:45 ( .
. 15 .
21:31:00 . Download 15
Caching
15 . 30 21:30:45 .
21:31:15 Caching 15
.
-: VaryByParam

74

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Caching ASP.NET
Caching ASP.NET
VaryByParam Caching
HTML .
Caching :
><%@ OutputCache Duration = "120" VaryByParam = "name" %
Label .
name . Label
21:22:10 . Caching
.
VaryByParam none Cache .
name
Caching . 30 :
http://www.iranasp.net/myexample.aspx?name=mahmoud
ASP.NET
name . Label 21:22:40 Label
name mahmoud .
15 .

75

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

21:22:40 . Caching .
5 21:23:00 :
http://www.iranasp.net/myexample.aspx?name=mahmoud&student_no=80622121
. VaryByParam
ASP.NET .
OR .
.
120
. Caching
VaryByParam Caching )
(.
ASP.NET .
* VaryByParam
.
. none
.
- Caching 3

76

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Caching ASP.NET
Caching . UserControl
) ascx( . Caching UserContol
. ASP.NET Caching
UserControl Caching :
><%@ OutputCache Duration = "30" VaryByParam = "none" %
UserControl Label .
Label . Page_Load
UserControl Label .
Label .
30 Label Label
UserControl . 30
. Label .
UserControl Caching
. Caching
UserControl VaryByParam
Caching . ASP Caching
) ( . Caching
ASP.NET .
77

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET


ASP.NET .
ASP.NET

.
. MSDN .
msdn.microsoft.com/library/default.asp@url=_2flibrary_2fenus_2fcpguide_2fhtml_2fcpcondevelopinghigh-performanceaspnetapplications.asp
:
Session State .
Session State .
Session Page False
.
Session web.config .
.

1 iranasp.net
78

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

.
round trip .

.
.

.
HTML .
Page.IsPostback .
Page.IsPostback ) (round trip .
.
View State .
View State Session State
. .
.
" Strict="true .

79

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

early binding Page .


.
VB.NET JScript.NET ASP
) (
. .
Stored Procedure .
) (query
) (stored procedure .
) (DBMS
. (driver) SQLServer
OLEDB ODBC
.
Data Reader .
Data
Reader . Data Set .
Caching .

80

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Caching ASP.NET . caching .


caching HTML
.
Debug .

Debug .

81

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET

ASP.NET

.

.

.
( ( .
.
ASPASP.NET
ASP.NET ASP . ASP
IIS ASP.NET
.
ASP.NET

1
82

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

:Authentication
) ( .
.
Authentication.
:Authorization
.
:Impersonation
.
)(Impersonated . Impersonation (Server
)Process ) (Client .

83

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET

ASP.NET Email
.
www. iranasp.net/download/pourshahid02.zip :
email .
System.Web.Mail
.
><%@ Import Namespace="System.Web.Mail" %

Instance .
Dim mail As New MailMessage

:
:mail.From email
:mail.To email
:mail.Subject
:mail.Body email HTML
1
84

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

:mail.BodyFormat
( Local) :SmtpMail.SmtpServer
:SmtpMail.Send(mail)
Submit
.
Label
.
<%@ Page Language="VB" EnableSessionState="False"
EnableViewState="False" Trace="False" Debug="False" Strict="True" %>
<%@ Import Namespace="System.Web.Mail" %>
<script language="VB" runat=server>
Sub Page_load(Sender as Object, E as EventArgs)
If request.form("EmailAddress") = "" Then
dim strResponse as string = "<h2>Send Email using ASP.NET formatted in
HTML</h2>"
lblMessage.Text = strResponse
Else
dim strResponse as string = "You just sent an email message formatted in HTML
to:<br><h2>" &request("EmailAddress") & "</h2>"
lblMessage.Text = strResponse
End If

85

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

End Sub
Sub btn_Click(sender as Object, e as System.EventArgs)
If request.form("EmailAddress") <> ""
Dim mail As New MailMessage
mail.From = youraddress@domain.com
mail.To = request.form("EmailAddress")
mail.Subject = "Message sent using ASP.NET and CDONTS"
mail.Body = "HTML Message sent from Iranasp.net using ASP.NET and
Cdonts<br>Wonder how this is done?<br><br>Wonder How to setup CDONTS?"
mail.BodyFormat = MailFormat.Html
SmtpMail.SmtpServer = "LocalServerName"
SmtpMail.Send(mail)
End If
End Sub
</script>
<html>
<head>
</head>
<body>
<h1 align="center">Sending Email via ASP.NET and CDONTS..</h1>
<b>How do I setup my server to use CDONTS?</b>
<br/>
<br/>
<br/>
<br/>
86

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

<asp:Label id="lblMessage" Font-Name="Verdana" Width="400px"


BorderStyle="solid" BorderColor="#cccccc" runat="server"/>
<form method="post" name="form1" runat="server" runat="server">
Email Address:<input type="text" name="EmailAddress" size="30" value=""><br><br>
<input type="Submit" id="btnSubmit" OnServerClick="btn_Click" value="Sending
Email with ASP.NET" name="b1" runat="server" />
</form>
</body>
</html>

87

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Smart Navigation

) smart navigation !(
.
Smart Navigation
Smart Navigation ASP.NET .

.
HTTP .
.

scrolling
.
.

)
listbox . (.

1
88

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Smart Navigation
! IE 5
. Smart Navigation
. Smart
Navigation . ASP.NET Smart Navigation
.
Smart Navigation :
.
Scroll .
.
) (History .
(!) Postback
.
- .
.

89

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Smart Navigation )> (Page directive : <%@ %


web.config . Page Directive
:
><%@ Page SmartNavigation=true %
web.config :
><Configuration
><System.web
><Pages SmartNavigation=true /
></System.web
></Configuration
) (hidden IFrame )(load
)(render .
Professional ASP.NET 1.0Wrox

90

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET

. ASP. NET
ASP.NET .
ASP.NET .
.asax
Global.asax .
ASP.NET .
ASP.NET .
.ascx
ASP.NET (User Control).
ASP.NET ) (
. ASP.NET
.
.
.asmx

1
91

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

XML .
.NET.

.
.aspx
ASP.NET ASP.NET
.
.axd
tracing ASP.NET ASP.NET
HTTP .
.vsdisco
XML .
VSDISCO .
.htm
HTML .
.xml

92

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

XML ASP.NET . XML



.
.vb
ASPX ASCX
ASP.NET . code-
behind .
.cs
vb. C#.
.config
web.config.
.
) (debuging ) (authentication ) (tracing (state
)management ) (globalization & localization .
) ASP.NET (

www.nashreoloom.com/showbooks.aspx@id=110

93

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

codebehind

codebehind
codebehind )
(ASP.NET . ASPX ) ASMX
(ASCX aspx.cs- ) C# VB.NET ( aspx.vb
. HTML .
:

HTML .

) VS.NET (


VS.NET >" <Script runar="server
codebehind .

1
94

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

codebehind
ASP.NET object . ASP.NET ASPX
System.Web.UI.Page .
)( ASP.NET
cache .
ASPX
.
System.Web.UI.Page .
codebehind
ASPX System.Web.UI.Page
:
><%@ Page Inherits="YourNamespace.NewPage" %
NewPage
System.Web.UI.Page . ASP.NET \bin
cache ) (Global Assembly Cache NewPage
.
.
(www.angrycoder.com/default.htm) angryCoder .
codebehind .
95

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

codebehind ASP.NET .
ASP.NET ( codebehind
dll \bin( . Src
:
><%@ Page Src="NewPage.aspx.cs" Inherits="YourNamespace.NewPage" %
VS.NET codebehind
:
"<%@ Page Codebehind="NewPage.aspx.cs" Inherits="YourNamespace.NewPage
>%
VS.NET codebehind dll
\bin . Src
Codebehind Page Src
codebehind .

codebehind .
dll \bin codebehind Inherits
. Src codebehind .
ASP.NET JIT codebehind .
96

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

VS.NET Codebehind .
VS.NET .

97

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Namespace

Namespace namespace
.
NET Framework.
)namespace ( .
.
.
NET Framework.
ASP.NET .
. :
Public Class NewClass
][Procedures and Functions
End Class
Public Class NewClass
][Procedures and Functions
End Class

1
98

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

.
.
:
Namespace One
Public Class NewClass
][Procedures and Functions
End Class
End Namespace
Namespace Two
Public Class NewClass
][Procedures and Functions
End Class
End Namespace
NewClass
. One.NewClass
Two.NewClass .
.

.

99

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

) ( .
.

.
ASP.NET .
ASP.NET
. .
ASP.NET . System Microsoft .
.
System
System ASP.NET NET
Framework. . System
. System
9 . ) System 8 )
ASP.NET :
System
System.ComponentModel.Design
System.Data
System.Drawing
System.Web.SessionState
100

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

System.Web
System.Web.UI
System.Web.UI.WebControls
System.Web.UI.HTMLControls
) ) System Visual Studio.NET VS.NET
ASP.NET . .
:System.ComponentModel.Design

NET Framework. .
:System.Data
ADO.NET .
: System.Drawing

System.Drawing

System.Drawing.Drawing2D System.Drawing.Imaging
.
: System.Web /
. ) HTTPRequest
HTTP( ) HTTPResponse
( .
101

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

: System.Web.SessionState

: System.Web.UI

ASP.NET
. Page
. Active Server Page Page :
Server Request Response ApplicationSession.
: System.Web.UI.HTMLControls HTML
.
HTML " runat="server
"id="controlname .
: System.Web.UI.HTMLControls
HTML
.
.
: System.IO
.

102

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

: System.Data.OleDb
ADO .

: System.Data.SqlClient

Microsoft SQL Server ADO .

: System.Web.Security

ASP.NET .
.
: System.XML XML
.
Microsoft
System .NET
.
.
: Microsoft.VisualBasic CLR Visual Basic.NET .
Visual Basic.NET .
.
: Microsoft.CSharp
#C .
103

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

: Microsoft.JScript
JScript .
: Microsoft.Win32 hive
.
ASP.NET
. .
ASP.NET
ASP.NET . ) (Directive
@Import ASPX Imports codebehind
C# using .
System.Web.UI.WebControls ASP.NET .
><%@ Import namespace = "System.Web.UI.WebControls" %
codebehind .
)Imports System.Web.UI.WebControls (vb.net
)using System.Web.UI.WebControls; (C#

) Import Imports (

104

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET codebehind
. System.Web.UI.HTMLControls
Imports
System.Web.UI.HTMLControls . .Imports System
VS.NET .
.NET
. Intellisense . ASP.NET
:
><%@ Import namespace = "System.Web.UI.WebControls" %
><%@ Import namespace = "System.Web.UI.HTMLControls" %
><%@ Import namespace = "namespace name" %
...
codebehind :
Imports System.Web.UI.WebControls
Imports System.Web.UI.HTMLControls
Imports namespace

) ASP.NET (

www.nashreoloom.com/showbooks.aspx@id=110

105

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

upload ASP.NET

upload ASP.NET .
Upload .
HTML .
ASP.NET .
. ASP
component ASP.NET .
Upload.aspx:
><HTML
><HEAD
><TITLE>Uploading File...</TITLE
>"<Script language="vb" runat="server
)sub page_load(s as object,e as EventArgs
If Not (MyInputFile.PostedFile Is Nothing) Then
)"MyInputFile.PostedFile.SaveAs("c:\filename.ext
)"Response.write("Your File was saved on the server...
End If
end sub
></script
></HEAD
><BODY

1
106

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

>"<FORM method="post" encType="multipart/form-data


>"<input id="MyInputFile" type="file" name="MyInputFile" runat="server
>"<input type="submit" value="Submit
></FORM
></BODY
></HTML
:
Client
.
encType
:
"encType="multipart/form-data
HTML :
>"<input id="MyInputFile" type="file" name="MyInputFile" runat="server
ASP.NET
" runat="server .
Client :
><body
>"<form method="post" encType="multipart/form-data
107

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

>"<INPUT id="MyInputFile" type="file" name="MyInputFile" runat="server


>"<input type="submit" value="Submit
></form
></body
Server

.
) MyInputFile ( .
PostedFile .
. PostedFile
. :
If Not (MyInputFile.PostedFile Is Nothing) Then
. SaveAs PostedFile
.
.
)"Response.write("Your File was saved on the server successfuly...
:
>"<script language="vb" runat="server
)sub page_load(s as object,e as EventArgs
108

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

If Not (MyInputFile.PostedFile Is Nothing) Then


MyInputFile.PostedFile.SaveAs("c:\filename.ext")
Response.write("Your File was saved on the server...")
End If
end sub
</script>

: PostedFile
. :ContentLength
: ContentType: MIME
.
: MIME )
application/msword audio/mpeg image/jpeg image/gif text/plain
( ...audio/wav video/mpeg application/octed-stream
). : FileName

(C:\images\personal\myface.jpg
upload stream : InputStream

.

109

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

request 4096 ) 4 kb
( . 4 kb .
web.config machine.config > <system.web

><httpRuntime maxRequestLength="1000000"/
maxRequestLength .
. ) ( 1 MGB .
web.config :
Configuration file : web.config
>? "<?xml version="1.0" encoding="utf-8
> <configuration
><system.web
><httpRuntime maxRequestLength="1000000" /
></system.web
></configuration

110

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

ASP.NET Caching

Fragment ASP.NET Caching


. Data Caching Page Output Caching Caching
ASP.NET Caching - 1
:Caching
.
. :Caching
client browsers. Web server, proxy server Caching
: Caching
Output caching
Fragment caching
Data caching

Output Caching-2
Output Caching

iranasp.net 1
111

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Output Caching
cache .
cache .
Output Caching
CPU .
Output Caching
.
Output Caching .aspx asmx. ascx.
.
@OutputCache
Output Caching :
><%@ OutputCache Duration="600" Location="Any" VaryByParm="none" %
:
][C#
;))Response.Cache.SetExpires(DateTime.Now.AddSeconds(600
;)Response.Cache.SetCacheability(HttpCacheability.Public
OutputCaching
:Duration cache .
.
112

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

:Location cache .
Server cache .
Downstream cache proxy server .
Client cache .
Any cache .
None cache .

:VaryByParam cache

QueryString Form .
><%@ OutputCache Duration="10" VaryByParam="location;count" %

:VaryByHeader cache

HTTP header .
><%@ OutputCache Duration="60" VaryByHeader="Accept-Language" %

:VaryByCustom " "Browsercache

.
HttpApplication.GetVaryByCustomString
Global.asax .

113

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Fragment Caching-3
o

cache

cache . Fragment Caching


.
o

User

Control .
o

@OutputCache

.
o

VaryByParam

VaryByControl.
o

cache Location

cache .

:VaryByControl @Outputcache

. .
cache ) (properties .
][*.ascx
><%@ Language="C#" %
"<%@ OutputCache Duration="10" VaryByControl="State;Country
>VaryByParam="*"%
><script runat=server
114

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

{ public String State


} ;get { return state.Value
} } ;set { state.Value = State
{ public String Country
} ;get { return country.Value
} } ;set { country.Value = Country
></script

cache .

cache .
.

cache

. exception .
.

Data Caching-4
data cache DataSet
cache:
Cache ("counter") = mycount.text
Application
.
115

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

cache
cache .
Public Function GetProductData() As DataSet
If (IsNothing(Cache("ProductData")) Then
)(Cache("ProductData") = LoadDataSet
End If
)"Return Cache("ProductData
End Function
cache .
cache Cache.Insert
Cache.Add .
Cache.Remove cache .

116

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET Context
.
ASP.NET .
Session Application QueryString
. Context
Server.Transfer . Context Session
:
;)"Context.Items.Add("NameOfVariable","ValueOfVariable
;)"Server.Transfer("WebForm2.aspx

:
;)(Label1.Text=Context.Items["NameOfVariable"].ToString
object
Cast .
Session

. .
1
117

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

Imports System.Collections
Public Class StaticContainer
Private Shared thing As Hashtable
Public Shared Sub InitThing()
thing = New Hashtable()
End Sub
Public Shared Sub KillThing()
thing.Clear()
thing = Nothing
End Sub
Public Shared Sub AddContainer(ByVal key As Object)
thing.Add(key, New ArrayList())
End Sub
Public Shared Sub RemoveContainer(ByVal key As Object)
thing.Remove(key)
End Sub
Public Shared Sub AddToContainer(ByVal newname As String, ByVal index As
Integer,
ByVal stuff As String, ByVal key As Object)
Dim temp As ArrayList = thing.Item(key)
thing.Remove(key)
Dim t As New triple()
t.name = newname
t.ID = index
t.data = stuff
temp.Add(t)
118

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

thing.Add(key, temp)
End Sub
Public Shared Function GetEntry(ByVal x As Integer, ByVal key As Object) As triple
Dim temp As ArrayList = thing.Item(key)
Dim result As triple
If temp.Count > x And x >= 0 Then
result = CType(temp(x), triple)
End If
Return result
End Function
End Class
Public Structure triple
Public name As String
Public ID As Integer
Public data As String
End Structure
: Global.asax
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the application is started
StaticContainer.InitThing()
End Sub
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the session is started
Session.Add("key", DateTime.Now.Ticks.ToString("x"))
StaticContainer.AddContainer(Session.Item("key"))
119

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

End Sub
Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the session ends
StaticContainer.RemoveContainer(Session.Item("key"))
End Sub
Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the application ends
StaticContainer.KillThing()
End Sub
. Session Container ID
Session Hashtable
: .
StaticContainer.AddToContainer(TextBox1.Text, Integer.Parse(TextBox2.Text),
TextBox3.Text, Session.Item("key"))
Dim t As triple = StaticContainer.GetEntry(Integer.Parse(TextBox4.Text),
Session.Item("key"))
ListBox1.Items.Add(t.name)
ListBox1.Items.Add(t.ID.ToString())
ListBox1.Items.Add(t.data)

. triple
http ://www.dotnetjunkies.com/tutorials.aspx?tutorialid=600:
120

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET

ASP.NET .CDOSYS
IranASP.NET
E-mail
ASP.NET .

ASP.NET .
:
][C#
;)(MailMessage objMM = new MailMessage
;"objMM.From = "me@myhost.com
;"objMM.To = "you@yourhost.com
;"!objMM.Subject = "Welcome
;"objMM.Body = "Welcome to IranASP.NET
;)SmtpMail.Send(objMM

.
Exception :
The "SendUsing" configuration value is invalid.
1
121

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

.
: Service Pack 3 Microsoft Exchange Server
! host . .

.
SMTP Server IIS .
.
.
. CDOSYS .CDONTS
2000 NT . CDOEX Exchange
.
CDOSYS
CDONTS . :
SMTP Server : .
: 25 .
username password SMTP Authentication.

122

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

. :

.
. :
! IranASP.NET
.
IranASP.NET
:
[C#]
int cdoSendUsingPickup = 1;
string cdoSendUsingMethod = "http://schemas.microsoft.com/
cdo/configuration/sendusing";
string cdoSMTPServerPickUpDirecory = "http://schemas.microsoft.com/
cdo/configuration/smtpserverpickupdirectory";
// You can uncomment each line when you need it!
//string cdoSMTPServer = "http://schemas.microsoft.com/
cdo/configuration/smtpserver";
//string cdoSMTPServerPort = "http://schemas.microsoft.com/
cdo/configuration/smtpserverport";
//string cdoSMTPConnectionTimeout = "http://schemas.microsoft.com/
cdo/configuration/smtpconnectiontimeout";
//string cdoSMTPAuthenticate = "http://schemas.microsoft.com/
123

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

cdo/configuration/smtpauthenticate";
//string cdoSendUserName = "http://schemas.microsoft.com/
cdo/configuration/sendusername";
//string cdoSendPassword = "http://schemas.microsoft.com/
cdo/configuration/sendpassword";
//For CDOSYS, the pickup directory is located at
c:\inetpub\mailroot\pickup
string strPickup = "c:\\inetpub\\mailroot\\pickup";
CDO.Message objMM = new CDO.Message ();
ADODB.Fields Flds = objMM.Configuration.Fields;
Flds[ cdoSendUsingMethod ].Value = cdoSendUsingPickup;
Flds[ cdoSMTPServerPickUpDirecory ].Value = strPickup;
Flds.Update ();
objMM.HTMLBodyPart.Charset = "utf-8";
objMM.MimeFormatted = true;
objMM.From = "me@myhost.com";
objMM.To = "you@yourhost.com";
objMM.Subject = "Welcome!";
objMM.HTMLBody = "<HTML><HEAD></HEAD><BODY><b>Welcome to
IranASP.NET!</b></BODY></HTML>";
124

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

objMM.Send ();
. HTMLBody utf-8
GAC bin DLL
:( bin )
adodb.dll
Interop.CDO.dll
. 2000
. Visual Studio .NET References
:
1.

CDO for Windows 2000

msdn.microsoft.com/library/default.asp@url=_2flibrary_2fenus_2fcdosys_2fhtml_2f_cdosys_about_cdo_for_windows_2000.asp

2.

CDO for Win2000: Messaging Configuration

msdn.microsoft.com/library/default.asp@url=_2flibrary_2fenus_2fcdosys_2fhtml_2f_cdosys_messaging_configuration.asp

3.

CDO for Win2000: Configuring the Message Object


125

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

msdn.microsoft.com/library/default.asp@url=_2flibrary_2fenus_2fcdosys_2fhtml_2f_cdosys_configuring_the_message_object.asp

4.

CDO for Win2000: Creating and Sending a Message

msdn.microsoft.com/library/default.asp@url=_2flibrary_2fenus_2fcdosys_2fhtml_2f_cdosys_messaging_examples_creating_and_sending_a_mes
sage.asp

5.

PRB: Microsoft Exchange 2000 Server Service Pack 3 Security

Modification and CDOEX/CDOSYS


support.microsoft.com/@kbid=324037

6.

Sending Email Via an External SMTP Server Using CDO

www.asp101.com/articles/john/cdosmtprelay/default.asp

126

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET

) (template .
) (...

.
. .
.
.

) Main Part (
. ) (
) (Main Part
.
.
Main Part ) formsbuttons datagrid
.(...

1
127

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

.
.
.
)(Frame
HTML
. HTML
)(DOM JavaScript .
.

. (Main
)Part .
.
Address bar
refresh navigating
!

ASP.NET
User controls .
.
128

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

.
. code behind
.
User Control

user
control .
. :
)(1
)(2

)(3 )(Main Part

3 Main Part .
3 1 2
) User Control UC (
. )(Panel . 1 ) :
(Panel_logo.ascx
---Panel_logo.ascx file---

129

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

<%@ Control Language="vb" AutoEventWireup="false" Inherits="site.Panel_logo"


TargetSchema= "http://schemas.microsoft.com/intellisense/ie5" %>
<IMG height="74" src="images/logo.gif" width="370" vspace="2" border="0">
. panel_logo
.
. runat=server UC :
.
. HTML
.
:
---Panel_right.ascx file--<%@ Control Language="vb" AutoEventWireup="false"
Codebehind="Panel_right.ascx.vb" Inherits="site.Panel_right" TargetSchema=
"http://schemas.microsoft.com/intellisense/ie5" %>
<table >
<tr>
<td id="td1" runat="server"><A href="index.aspx"> Home Page </A></td>
<td id="td2" runat="server"><A href="search.aspx"> Searching </A></td>
<td id="td3" runat="server"><A href="AboutUs.aspx"> About Us </A></td>
130

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

</tr>
</table>
.
Codebehind runat=server < td>
.
property .
: Codebehind .
---Panel_right.ascx.vb file--Protected WithEvents td1 As System.Web.UI.HtmlControls.HtmlTableCell
Protected WithEvents td2 As System.Web.UI.HtmlControls.HtmlTableCell
Protected WithEvents td3 As System.Web.UI.HtmlControls.HtmlTableCell
: property . td1,td2,td3
Public WriteOnly Property current_page() As Integer
Set(ByVal Value as Integer)
Select Case Value
Case 1
td1.InnerHtml = "Home Page"
Case 2
td2.InnerHtml = "Searching"
Case 3
td3.InnerHtml = "About Us"
131

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

End Select
End Set
End Property
searching 2 current_page
searching
.
.
: template.aspx
---template.aspx--<%@ Register TagPrefix="Mysite" TagName="Panel_right" Src="Panel_right.ascx"
%>
<%@ Register TagPrefix="Mysite" TagName="Panel_logo" Src="Panel_logo.ascx" %>
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="template.aspx.vb"
Inherits="site.template"%>
<HTML>
<head> My site </head>
<body>
<table>
<tr>
<td colspan="2">
<mysite:panel_logo id="panel_logo1" runat="server"></mysite:panel_logo>
</td>
</tr>
132

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

(Main < [ ] td>


Part)
</td>
<td>
<mysite:panel_right id="panel_right1" runat="server"></mysite:panel_right>
</td>
<tr>
</tr>
</table>
</body>
</HTML>
)
. ( page directive
( aboutus.aspx) ) :
---aboutus.aspx--<%@ Register TagPrefix="Mysite" TagName="Panel_right" Src="Panel_right.ascx"
%>
<%@ Register TagPrefix="Mysite" TagName="Panel_logo" Src="Panel_logo.ascx" %>
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="aboutus.aspx.vb"
Inherits="site.aboutus"%>
<HTML>
<head> My site </head>
<body>
<table>
133

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

><tr
>"<td colspan="2
><mysite:panel_logo id="panel_logo1" runat="server"></mysite:panel_logo
></td
></tr
><td ... : 1-...2-...
></td
><td
"<mysite:panel_right id="panel_right1" current_page="3
>runat="server"></mysite:panel_right
></td
><tr
></tr
></table
></body
></HTML
directive Page "
)" (Main Part current_page
panel_right 3 .
.
. 200

. panel_logo :

134

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

>"<IMG height="74" src="images/adv.gif" width="570" vspace="2" border="0


! ...
.
. panel_right.ascx case
select code behind ! current_page
. visible
) ( .
. .
caching
.
:
.
HTML HTML
.
.
.
:

135

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

.
. .
.
HTML . HTML
HTML
.
.
.
... .
:

HTML

.
.

. :

) (Main Part .
136

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

... IranASP.NET
. ) (Main Part .
.
)(Main Part . Main
Part .
" "
.
.
.
. . HTML
Main Part :
"<%@ Register TagPrefix="Mysite" TagName="Panel_right" Src="Panel_right.ascx
>%
><%@ Register TagPrefix="Mysite" TagName="Panel_logo" Src="Panel_logo.ascx" %
>Inherits="site.template"%
><HTML
><head> My site </head
><body
><table
><tr
>"<td colspan="2

137

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

<mysite:panel_logo id="panel_logo1" runat="server"></mysite:panel_logo>


</td>
</tr>
<td>
:
[Codes that are for main part of the page, must put here.]

: HTML
</td>
<td>
<mysite:panel_right id="panel_right1" runat="server"></mysite:panel_right>
</td>
<tr>
</tr>
</table>
</body>
</HTML>
.
: (segment_top.ascx)
---segment_top.ascx--<%@ Register TagPrefix="Mysite" TagName="Panel_logo" Src="Panel_logo.ascx" %>
<%@ Control Language="vb" AutoEventWireup="false"
138

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

Codebehind="segment_top.ascx.vb" Inherits="site.segment_top" TargetSchema=


"http://schemas.microsoft.com/intellisense/ie5" %>
<HTML>
<head> My site </head>
<body>
<table>
<tr>
<td colspan="2">
<mysite:panel_logo id="panel_logo1" runat="server"></mysite:panel_logo>
</td>
</tr>
<td>
. directive HTML
. code behind
: (segment_down.ascx)
---segment_down.ascx--<%@ Register TagPrefix="Mysite" TagName="Panel_right" Src="Panel_right.ascx"
%>
<%@ Control Language="vb" AutoEventWireup="false"
Codebehind="segment_down.ascx.vb" Inherits="site.segment_down" TargetSchema=
"http://schemas.microsoft.com/intellisense/ie5" %>
</td>
<td>
<mysite:panel_right id="panel_right1" runat="server"></mysite:panel_right>
139

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

></td
><tr
></tr
></table
></body
></HTML
directive . HTML
) well formed(
. .
VS.NET
.


. .
) (
. panel_right codebehind
.
---segment_down.ascx.vb--Protected WithEvents Panel_right1 As Panel_right
:
140

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

WriteOnly Property current_page() As Integer


Set(ByVal Value As Integer)
Panel_right1.current_page = Value
End Set
End Property
.
:
---template.aspx--<%@ Page Language="vb" AutoEventWireup="false" Codebehind="template.aspx.vb"
%>
<%@ Register TagPrefix="mysite" TagName="segment_down"
Src="segment_down.ascx" %>
<%@ Register TagPrefix="mysite" TagName="segment_top" Src="segment_top.ascx"
%>
<mysite:segment_top id="Segment_top1" runat="server"></ mysite:segment_top>
<mysite:segment_down id="Segment_down1" runat="server"></
mysite:segment_down>
. page directive
: aboutus.aspx
---aboutus.aspx---

141

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

"<%@ Page Language="vb" AutoEventWireup="false" Codebehind="aboutus.aspx.vb


>%
"<%@ Register TagPrefix="mysite" TagName="segment_down
>Src="segment_down.ascx" %
"<%@ Register TagPrefix="mysite" TagName="segment_top" Src="segment_top.ascx
>%
>< mysite:segment_top id="Segment_top1" runat="server"></ mysite:segment_top
... -...2...-1 :
< mysite:segment_down id="Segment_down1" runat="server" current_page=" 3" ></
>mysite:segment_down
.
current_page .
.
) : panel_adv.ascx (
"<%@ Register TagPrefix="Mysite" TagName="Panel_adv" Src="Panel_adv.ascx
>%
><mysite:panel_adv id="panel_adv1" runat="server"></myite:panel_adv
! " "
. HTML
. HTML
.

142

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com


aspx . .
HTML aspx

. .
aspx
.
.
www.hudhud-dubai.com
) www.irantbc.com( .

143

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

.NET Framework 1.1

1.1
.
1,1
.

PDA
NET Framework 1.0.
Microsoft Mobile Internet Toolkit
.
1,1
Visual Studio .NET 2003 .
:
Side-by-Side 1,1
)(Component
(Version Control).

1
144

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

.

. .
.
msdn.microsoft.com/netframework/productinfo/versioncomparison/default.asp
Windows Forms
1,1 (Assembly DLL( Windows Forms
. Microsoft Windows Forms
) (Web based Windows Forms
.
ASP.NET
" " Code Access
Security ASP.NET ) (Web Services
.
" " CLR
.
ISP .
ODBCORACLE
145

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

1,1 )(Data Provider - Driver


ODBC ORACLE
. 1,1 .
ODBC )(Namespace System.Data.Odbc
ORACLE System.Data.OracleClient .
Smart Client
Microsoft .NET Compact Framework
Smart Client .
Pocket PC 2000/2002 Pockect PC 2002 Phone Edition
Windows CE .NET 4.1 ) Windows CE
.NET (.
Microsoft .NET Compact Framework CLR
Windows Forms .

.

Visual Studio .NET 2003 .
6IPv6
146

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

1.1 6
IPv6 .
.

) (scalibility
)(performance 1,1 .
) ) Secure Code
.
: What's New in the .NET Framework 1.1
msdn.microsoft.com/netframework/productinfo/overview/whatsnew.asp

147

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

10 .1NET 2003 Visual Studio


Visual Studio .NET 2003
.
- 1
VS .NET 2003 Pockect PC
Tablet PC . Microsoft Visual Basic
.NET 2003 Microsoft Visual C# .NET 2003.
- 2
NET Framework 1.1.
.
- 3 !
Wizard Visual Basic 6.0 Visual Basic .NET
User Controls .
- 4 !Java

1
148

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Visual J# .NET VS .NET 2003 Java


Java .
- Enterprise Instrumentation Framework 5EIF
VS .NET 2003 Enterprise Instrumentation Framework
) (monitoring ) (run-time .
- 6 XML
VS .NET 2003 XML
WS-Attachments WS-Security WS-Routing DIME .
- 7
) (debugger
.
- ADO.NET 8
) (Data Provider ADO.NET Oracle 8i
Oracle 7i ODBC .
- 9 online

149

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Help online
.
- 10 ) (IDE
VS. NET 2003
.

Top 10 Reasons to Upgrade to Visual Studio .NET 2003 :


msdn .microsoft.com/vstudio/productinfo/vstudio03/topten/upgrade.asp

150

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Thread ASP.NET

Threading ASP.NET
Application Domain .
Visual Studio.NET
.
Threading . System Threading
. Help VS.NET
Thread Safety
.
Thread .
.

Thread ) (Process
.
.
) VS.NET MS Access
WinAmp !). Windows
1
151

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

. ( Ctrl + Shift + Esc 2000


)Windows Task Manager Processes
. :
devnev.exe VS.NET .
IExplore.exe ( IE ( .
. desktop
Explorer . End Process
Desktop !!
.
IIS INETinfo.exe .
.
ASP.NET IIS
ASP.NET . ASP_wp.exe ASP Worker Process
. ASP.NET .
. ) (
ASP.NET IIS ) INETinfo.exe).

.

152

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Thread
Thread Thread
) ) .
Thread .
) (.
Processes Windows Task Manager .
View Select Columns . Thread Count
OK . Processes
Threads . .
IExplore.exe . Processes Windows Task
Manager . IExplore.exe
.
. Thread.
Explorer.exe . Threads .
Thread . Windows
Explorer ) Start ( Explore.
Explore.exe !

153

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Threads Explore.exe .
) Windows Explorer ( .
.
Windows Explorer
Explorer.exe Thread .
Thread Thread .
.

. Thread Thread
. .
Thread .
.
Thread . Thread 120
. Thread Thread
Thread .
Thread Thread .

154

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Thread ASP.NET
Thread
ASP_wp.exe INETinfo.exe
ASP.NET . Application Domain
ASP.NET .
Application Domain
ASP.NET
Thread
Thread . 1000
.
IIS Restart
.
.
IIS Restart Thread Restart
Thread
. Thread
Restart )( .

155

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Application Domain
. Application Domain .
Application Domain ASP.NET .NET .
Application Domain . Application Domain
. Application Domain
. . Application Domain .
Restart.
Application Domain Thread
.
Application Domain Thread
. :


Application Domains
Threads
Thread ASP.NET
.

156

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP_wp.exe Thread .
Machine.Config processModel
. 25 .
Thread Debugger
NET Framework SDK. .
Debugger .
QuickStart ASP .NET .
:
samples.gotdotnet.com/quickstart/aspplus/doc/debugcomsdk.aspx
.:
DbgCLR.exe
ASP.NET Code Behind )
( ) index.aspx.vb default.aspx.vb ( ...
ASP.NET Debugger .
ASPNET_wp.exe INETinfo.exe.
Debugger Tools | Debug Processes
Attach . INETinfo.exe
157

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Show System Processes


. ASPNET_wp.exe .
Debugger . Thread :
Debug Windows Threads .
Ctrl + Alt + H .
Thread debug .
Page_Load Breakpoint
.
Thread .
) Code Behind Debugger (
. Breakpoint Page_Load
. Threads ... .
:
ID Thread
Thread > <noname
Thread Location .
) Page_Load)

158

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

...
Thread
Thread . F5
Debugger . Thread
. Thread .
.
) ( .
Debugger .
Thread Threads . ) F11 (F10
) (
Page_Load !! ... . Threads.
Thread .
CLR .
) F11 (F10 . Thread
. Threads
Thread . Thread
Thread . Thread
Thread .
Thread .
:
159

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Thread .
Thread . Thread .
.
.
.
Thread .
.
.
.

) ( . CLR
.
.
.
. . ASP.NET
) Multi-Threading
Thread ( .
MultiThreading .

160

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

. Application
Cache
.
.
Thread-Safety
NET Framework.
. :
" ) static shared (VB.NET MultiThreaded
" .

. insert Thread-Safe
Thread delete )
( .
MultiThreaded )
Debugger Thread
(.

Thread-Safe .
161

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

.
.
)

!!(.

) (NET Framework Developer's Guide:
Threads and Threading
Threading
Thread Synchronization
MultiThreaded Applications
Application Domains and Threads
Professional ASP.NET 1.0 Wrox Press.

162

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET

ASP.NET .
ASP.NET .
:

- 1
- 2
- 3ASP.NET
- 4
- 5
- 6 Include
- 7 HTML

- 1
aspx ascx
. > <% @%
) (.

1
163

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Framework Page Import


. Page aspx
... .
ASP.NET VB / :
><%@ Page Language="VB" ContentType="text/xml" %
Page
. :
><%@ Page Trace="True" Debug="True" %
Import .
. Framework
. :
><%@ Import namespace="value" %
MSDN .NET Framework General
Reference Directive Syntax .
- 2

ASP.NET . :

164

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

>"<script runat="server" language="codelanguage" Src="pathname


Code goes here
></script
ASP.NET
. Language
. Page
. Script
Page .
.
Src .
.
.
][VB.NET
><html
>"<script language="VB" runat="server
)Sub EnterBtn_Click(Src As Object, e As EventArgs
"!Message.Text = "Hi " & Name.Text & ", welcome to ASP.NET
End Sub
></script
><body
>"<form runat="server
165

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

>Enter your name: <asp:textbox id="Name" runat=server/


><asp:button text="Enter" Onclick="EnterBtn_Click" runat="server"/
><p
><asp:label id="Message" runat=server/
></form
></body
></html
- 3ASP.NET
ASP.NET HTML .
> <form/ > <"form runat="server . <"span
>runat="server > <"asp:Label runat="server .
> <"form runat="server .
ASP.NET .
- 4
HTML ASP.NET
. : .
. <% > % .
. <% >=%
. :

166

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

<%@ Page Language="VB" %>


<script runat="server">
dim strMessage as string
sub page_load
strMessage="Hello!"
end sub
</script>
<html>
<head>
</head>
<body>
<form runat="server">
The Value Of strMessage is <%= strMessage %>
<p>
<% strMessage="Goodbye!" %>
The Value Of strMessage is <%= strMessage %>
</p>
</form>
</body>
</html>
.
- 5

. --%> < %-- ASP.NET .
167

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET .
.
- 6 Include
ASP.NET .
:
><!-- #include file | virtual = filename --
File Virtual . File
Include .
Virtual .
MyDir wwwroot :
><!-- #include virtual="/mydir/includefile.aspx" --
Include
.
- 7 HTML
ASP.NET HTML .
HTML . HTML ASP.NET

168

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

. HTML LiteralControl .
Text HTML ASP.NET .

169

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

XML ASP.NET

XML
.
xml dataset XMLDocument
.
XMLTextReader . XMLTextReader
) (ForwardOnly non-cached
.
:
)(Read DataReader .
)(ReadElementString .
Item Attribute .
HasAttributes Attribute .
:
XML :

1
170

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

<?xml version="1.0" encoding="utf-8" ?>


<Root>
<data>
<id>1</id>
<into date="2003-02-18" where=" "/>
<comment show="true" title="hi!" />
</data>
<Root>
XML id comment Attribute
:
Dim xrdr As New XmlTextReader(path)
Dim s, t, id As String
While xrdr.Read()
If xrdr.HasAttributes And xrdr.name="comment" Then
s = xrdr.item("show")
t = xrdr.item("title")
ElseIf xrdr.name="id" Then
id = xrdr.ReadElementString ()
171

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

End If
End While
)(xrdr.Close
XML
. .

172

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

XML
XML

. XML
XML . Access
: Load
Dim DS As New DataSet()
Dim strConnect As New
OleDbConnection(ConfigurationSettings.AppSettings("datasource"))
Dim objSQLAdapter As New OleDbDataAdapter("SELECT * from blog order by id
DESC", strConnect)
objSQLAdapter.Fill(DS, "blog")
Dim doc As XmlDataDocument = New XmlDataDocument(DS)
Dim writer As XmlTextWriter = New XmlTextWriter("D:\www\weblog\weblog.xml",
Nothnig)
writer.Formatting = Formatting.Indented
doc.Save(writer)
DataSet
XML . weblog.xml XML
. XML

1
173

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

XML . XML
.
XML ) (RSS . ASPX
Design HTML .
><asp:DataList id="theDataList" runat="server" Width="100%" dir=rtl CssClass=text
><ItemTemplate
>:<%# DataBinder.Eval(Container.DataItem, "news_date") %><br
>: <%# DataBinder.Eval(Container.DataItem, news_title") %><br><br
><%# DataBinder.Eval(Container.DataItem, "news_body") %><br
><hr
></ItemTemplate
></asp:DataList
><br
DataList . Load
:
)(Dim ds As New DataSet
)ds.ReadXml("d:\www\weblog\weblog.xml", XmlReadMode.Auto
theDataList.DataSource = ds
)(theDataList.DataBind
XML ASP.NET .
XML
174

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

.
:
Dim ds As New DataSet()
ds.ReadXml("http://www.website.com/weblog.xml",XmlReadMode.Auto)
theDataList.DataSource = ds
theDataList.DataBind

175

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET

ASP.NET
System.Drawing System.Drawing.2D
Bitmap Graphics :
)Dim bmp As New Bitmap (400, 400
)Dim g As Graphics = Graphics.FromImage (bmp
)g.Clear(Color. White
Graphics .
Draw Fill . Draw
Pen Fill Brush :
)Dim bru As New Solid Brush (Color.Red
)Dim ps As New Pen (Color. Blue
))g.FillRectangle (b, New Rectangle (-10, -10, 320, 220
)Dim rec As New Rectangle (-100, -75, 200, 100
)g.DrawPie (ps, rec, 0, 180
Response.contenttype
. Dispose Bitmap
Graphics :
1
176

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

"response.contenttype="image/jpeg
'Send the image to the viewer
(bmp.save (response.outputstream, imageformat.jpeg
)( bmp.dispose
)( g.dispose

.
Y :

Matrix
) (100 . Y 1
-1 Translate .
Graphics :
)Dim mt As Matrix = New Matrix (1, 0, 0, -1, 0, 0
)mt.Translate (150, 100
g.Transform = m
Graphics .

177

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

.
:
Dim pf(5) As PointF
' --------------pf(0) = New PointF(120, 120)
pf(1) = New PointF(180, 120)
pf(2) = New PointF(150, 90)
Pf(3) = New PointF(120, 90)
pf(4) = New PointF(120, 120)
g.FillPolygon (bru, pf)
' --------------bru.Color = Color.BlueViolet
pf(0) = New PointF(150, 90)
pf(1) = New PointF(180, 120)
pf(2) = New PointF(180, 180)
pf(3) = New PointF(150, 210)
pf(4) = New PointF(150, 90)
g.FillPolygon(bru, pf)
' ----------------bru.Color = Color.SteelBlue
pf(0) = New PointF(90, 90)
pf(1) = New PointF(150, 90)
pf(2) = New PointF(150, 210)
pf(3) = New PointF(90, 210)
178

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

pf(4) = New PointF(90, 90)


g.FillPolygon(bru, pf)

179

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET

ASP.NET

IIS ASP.NET .
ASP.NET IIS .NET Framework
) (Authentication
) (Authorization .
IIS ASP.NET
:
-1 HTTP SSL
.
IIS -2 NTLM) Integrated (Kerberos
DigestBasic Certificate . IIS
anonymous ) ( .
IIS

1
180

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

anonymous ) anonymous
" "User-Machine ( .
IIS -3 .
NTFS ACL .
IIS IP .
IIS -4 ) anonymous( ASP.NET
.
ASP.NET -5 . ASP.NET
Windows ASP.NET
Forms HTML
SQL Server Active Directory
. ASP.NET Passport
Passport .
ASP.NET -6 .
) UrlAuthorization Module HTTP (
) web.config > (<authorization .
) FileAuthorization Module .
(HTTP ACL

181

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

. .NET
web.config .
-7
ASP.NET ASP.NET
.
.
Authorization, and ,Building Secure ASP.NET Applications: Authentication :
Secure Communication
msdn .microsoft.com/library/default.asp@url=_2flibrary_2fenus_2fdnnetsec_2fhtml_2fsecnetlpmsdn.asp

182

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

4 2003

4 VB.NET C++.NET J#.NET C#.NET


.
.

][VB.NET
Dim x As Integer
Public x As Integer = 10

][J#.NET
;int x
;int x = 10

][C+ + .NET
;int x
;int x = 10

][C#.NET
;int x
;int x = 10

1
183

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

[VB.NET]
comment '
x = 1 ' comment
Rem comment

[J#.NET]
comment //
multiline */
/* comment
**/
Class Documentation
/*

[C+ + .NET]
comment //
multiline */
/* comment

[C#.NET]
comment //
multiline */

184

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

/* comment

[VB.NET]
nVal = 7

[J#.NET]
nVal = 7;

[C+ + .NET]
nVal = 7;

[C#.NET]
nVal = 7;

[VB.NET]
If nCnt <= nMax Then
nTotal += nCnt ' Same as nTotal = nTotal + nCnt.
nCnt += 1 ' Same as nCnt = nCnt + 1.
Else
nTotal += nCnt
nCnt -= 1
End If

185

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

[J#.NET]
if (nCnt <= nMax){
nTotal += nCnt;
nCnt++;
}

[C+ + .NET]
if(nCnt < nMax) {
nTotal += nCnt;
nCnt++;
}
else {
nTotal += nCnt;
nCnt--;
};

[C#.NET]
if (nCnt <= nMax)
{
nTotal += nCnt;
nCnt++;
}
else
{
nTotal +=nCnt;
nCnt--;
186

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

[VB.NET]
Select Case n
Case 0
MsgBox ("Zero")
'VB.NET exits the Select at the end of a Case
Case 1
MsgBox ("One")
Case 2
MsgBox ("Two")
Case Else
MsgBox ("Default")
End Select

[J#.NET]
switch(n) {
case 0:
System.out.println("Zero\n");
break;
case 1:
System.out.println("One\n");
break;
default:
System.out.println("?\n");
187

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

[C+ + .NET]
switch(n) {
case 0:
printf("Zero\n");
break;
case 1:
printf("One\n");
break;
case 2:
printf("Two\n");
break;
default:
printf("?\n");}

[C#.NET]
switch(n)
{
case 0:
Console.WriteLine("Zero");
break;
case 1:
Console.WriteLine("One");
break;
case 2:
188

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

Console.WriteLine("Two");
break;
default:
Console.WriteLine("?");
}
For

[VB.NET]
For n = 1 To 10
MsgBox("The number is " & n)
Next
For Each prop In obj
prop = 42
Next prop

[J#.NET]
for(n=1; n<11;n++)
System.out.println("The number is " + n);

[C+ + .NET]
for(int n=1; n<11; n++)
printf("%d\n",n);

[C#.NET]
for (int i = 1; i <= 10; i++)
189

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

Console.WriteLine("The number is {0}", i);


foreach(prop current in obj)
{
current=42;
}
While

[VB.NET]
While n < 100 ' Test at start of loop.
n += 1 ' Same as n = n + 1.
End While

[J#.NET]
while (n < 100)
n++;

[C+ + .NET]
while(int n < 100)
n++;

[C#.NET]
while (n < 100)
n++;

190

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

][VB.NET
)Public Sub ABC(ByVal y As Long
...
End Sub
)ABC(x
))ABC((x
y . ABC y
x .
.
)( .

][J#.NET
.

][C+ + .NET
;)MyMethod(i,j

][C#.NET
)( .
:
)void ABC(int x
{
191

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

...
}
:
)ABC(i

][VB.NET
)Public Sub ABC(ByRef y As Long
End Sub
)ABC(x
y ) ByRef ( . ABC y x
.

][J#.NET
][C+ + .NET
ABC .
)int ABC(long *py
)ABC(&VAR

ABC .
192

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

int ABC(long &y);


ABC(VAR);

[C#.NET]
: . C++ C#
void ABC(ref int x)
{
...
}
ABC(ref i);

[VB.NET]
Try
If x = 0 Then
Throw New Exception("x equals zero")
Else
Throw New Exception("x does not equal zero")
End If
Catch err As System.Exception
MsgBox("Error: " & Err.Description)
Finally
MsgBox("Executing finally block.")
End Try

193

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

Console.WriteLine("Executing finally block");


}

[C#.NET]
// try-catch-finally
try
{
if (x == 0)
throw new System.Exception ("x equals zero");
else
throw new System.Exception ("x does not equal zero");
}
catch (System.Exception err)
{
System.Console.WriteLine(err.Message);
}
finally
{
System.Console.WriteLine("executing finally block");
}

[VB.NET]
o = Nothing

[J#.NET]
195

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

stringVar = null;

[C+ + .NET]
[C#.NET]
o = null;

196

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET Whidbey

ASP.NET Whidbey

Microsoft ASP.NET .
DELL Marrill Lynch NASDAQ JetBlue USAToday
.
ASP.NET 170
ASP.NET .
.

"ASP.NET "Whidbey
ASP.NET - Whidbey
ASP.NET .

.
Whidbey :
1 iranasp.net
197

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com


Whidbey
.
. Whidbey
ASP.NET . Whidbey .
)(username/ password
)(personalization

Master Pages

) (site navigation
(site
)counter
)(theme
ASP.NET Web Part )(portal
Whidbey 45 ) (server control .
treeview ... .
198

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET 1.0 DataGrid


)(dropdownlist
) (help . Whidbey
. Visual Studio .NET -
Whidbey .
Whidbey
. > <:asp
300 WAP/WML XHTML Mobile
cHTML .
Whidbey
.


Whidbey ) (administrators ASP.NET
.
ASP.NET . Whidbey API
Web.config
Machine.config . XML
) (configuration .
199

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Whidbey
- ) (pre-compile aspx.
aspx. ascx.
.


ASP.NET
Whidbey .
Whidbey 64
64 . 32
64 Whidbey JIT
64 .
Whidbey cache .
cache
output cache
ASP.NET.

200

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Whidbey -
ASP.NET .
. Whidbey .
http://www.asp.net/whidbey .
Visual Studio .NET Whidbey
http://www.asp.net/whidbey/whitepapers/VSWhidbeyOverview.aspx .

ASP.NET "Whidbey" Overview


www.asp.net/whidbey/whitepapers/aspnetoverview.aspx@tabindex=0&tabid=1

201

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Session State ASP.NET

Session ASP.NET .
ASP.NET Session ASP .
Web.Config .
Global.asax
Session .
Session
Session State > <SessionState Web.Config
. Web.Config
:
<sessionState
"mode="Off|InProc|StateServer|SqlServer
"stateConnectionString="tcpip=127.0.0.1:42424
"=sqlConnectionString="data source= 127.0.0.1;userid=sa;password
"cookieless="true|false
"timeout="20
>/

1
202

Ramin.samad@yahoo.com

ASP.NET

m.bashiry@gmail.com

mode

) (Session State .
) Off : ( ) Inproc ( -
)StateServer ( ) SqlServer (.

stateConnectionString .
mode SqlServer.
sqlConnectionString

.
mode SqlServer.

cookieless

Boolean
Session State ASP.NET

203

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Session_End .
Global.asax :
>"<script language="VB" runat="server
)Sub Session_Start(sender As Object, e As EventArgs
End Sub
)Sub Session_End(sender As Object, e As EventArgs
End Sub
></script

Session
Session Page HttpSessionState
System.Web.SessionState . Session
) (Collection . Session Page_Load
.
Session .
><%@ Page Language="VB" %
204

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

<script language="VB" runat="server">


Sub page_load()
Session["name"] = "James";
End Sub
</script>
<HTML>
<body>
Hello <%=Session["name"]%>!
</body>
</HTML>

205

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET


.
. . .

. . .
.
:
- 1 : Nedstat Sitemitter . . .
- 2

Firewall
) ( .
.
.

1
206

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

ASP.NET
.
.( String )
IP (
ClientName = Request.UserHostName
ClientIP = Request.UserHostAddress
.(
REFERER = Request.ServerVariables.Item("HTTP_REFERER")
(Client)(
LANGUAGE = Request.ServerVariables.Item("HTTP_ACCEPT_LANGUAGE")
AGENT = Request.ServerVariables.Item("HTTP_USER_AGENT")
Platform = Request.Browser.Platform()
QUERY STRING (
QUERY STRING = Request.ServerVariables.Item("QUERY_STRING")
Browser (
Browser = Request.Browser.Browser()
Browser_Type = Request.Browser.Type()
Browser_Version = Request.Browser.Version()
207

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

(
Dim MyDateTime As New DateTime
)(MyDateTime = Now
)"Dim MyDate As String = MyDateTime.ToString("MM/dd/yyyy
)"Dim MyTime As String = MyDateTime.ToString("hh:mm:ss

Session_Start ) Global.asax (.

. . . .

208

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET


.
ASP.NET string .

.
ASP.NET .
String
.
.
( )(mid
mid :
)Mid(A, B, C
=A

=B
1
209

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

C=

Dim aString As String = "SomeString"


Dim bString As String
bString = Mid(aString, 3, 3) ' Returns "meS"
Response.Write(bString)

(
: Substring
.Substring(A, B)

A=
B=

Dim aString As String = "A String"


Dim bString As String
bString = aString.Substring(2, 6) ' Returns "String"
Response.Write(bString)

210

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

String.Concat
.
Dim myString As String
Dim aString(10) As String
Dim t As Integer
For t = 0 To 9
aString(t) = CStr(t)
Next t
myString = String.Concat(aString) ' Returns "0123456789"
Response.Write(myString)

(
String.Join
.
Dim shoppingItem(2) As String
Dim shoppingList As String
shoppingItem(0) = "Milk"
shoppingItem(1) = "Eggs"
shoppingItem(2) = "Bread"
shoppingList = String.Join(",", shoppingItem) 'Returns "Milk,Eggs,Bread"
Response.Write(shoppingList)

211

Ramin.samad@yahoo.com

ASP.NET

m.bashiry@gmail.com

( )(Insert
Insert

212

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

If s.Trim() <> "" Then


Response.Write(s & "<BR>")
End If
Next s

(Replace)(
Replace
:
Dim myString As String = "Shopping List"
Dim aString As String
aString = Replace(myString, "o", "i") ' Returns "Shipping List".
Response.Write(aString)

213

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Web.Config

Setup .
ASP.NET
XML Web.Config .

Setup
. Web
.
ASP.NET
... XML Web.Config
XML ) Tag ) HTML
(Case Sensitive).

.
Web .

.
1
214

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Web.Config
Web ASP.NET Web.Config
Visual Studio .NET Web
Application .
XML

.
Web.Config
. Web.Config
. Web.Config
Web .
main Sub1 Sub2
Web.Config Web.Config
Web.Config
Sub1 Sub2 Web.Config main
main .
Web.Config
.

215

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Web.Config
Web.Config ><configuration
><configuration/ .
Web.Config :
><configuration
><!--Some Configurations--
></configuration
Web.Config : .
><configsectons > <configsections/
.
Web.Config > <configuration > <configsections .
> <configsectons/ .
Web.Config
.

Location
Web.Config
Web.Config

216

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

> <location > <location/


:
>"<location path="url
><!--Configurations--
></location

> <globalization .
:
:culture .

requestencoding ) .( Unicode

:responseencoding .


Web.Config
. > <authentication ><authentication/

><authorization

><authorization/ Web.Config
ASP. NET
.

217

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

> : <authentication Web


. mode Windows Passport Form None
IIS Passport
cookie .
> : <authorization
Web.Config . > <allow > <deny
.

> <customerrors
.
.
: mode
On RemoteOnly Off . RemoteOnly
defaultredirect
) ( ASP.NET
. On
defaultredirect . Off
ASP. NET .

218

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

:defaultredirect Url mode


On RemoteOnly .

> <sessionState
.
Cookiless Cookie SessionID
true false : true SessionID false
.Cookie
mode :

:Off

:Inproc In-process .

:SQLServer SQL Server .

:StateServer Out-Of-Process .
timeout

219

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

> <compilation
:

: debug true false ) false (


.
true . false
.

:defaultlanguage )
(Dynamic .

220

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

IrMail ) ASP.NET (


.
... .
IrMail ASP.NET
.
:1 " "IrMail (IrMail
) Component .
:2 IrMail ) NET 1.1. ( . .NET 1.0
.

.

) (web applications
.
:

1
221

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

" "

Password


ASP.NET ASP
CDONTS ASP
ASP .
) (host .

.
NET Framework. . :


) (Dll Registry

222

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com


.NET .
ASP
.

.

.NET
ASP.NET
.
http://www.asp.net/ControlGallery/default.aspx?tabindex=2
.

.NET
.NET
.NET SmtpMail
wrapper ) Collaboration Data Objects for Windows 2000 (CDOSYS .

223

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

. SMTP
)(Authentication SmtpMail .
charset HTML . SmtpMail
. CDOSYS
.
: NET Framework. .
.

.
www.iranasp.net/articles/showarticle.aspx@articleid=111.htm
1 .
.
IrMail
.

.
.
www.iranasp.net 1
224

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

) .NET
(.
""
.
.

. :


) !(
.

.
.
.

225

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com


) (... .
.
!
.
.
.

) !( .
.
.
IrMail

.
) NET 1.1.). .NET )
( . .

226

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

IrMail .
. .
IrMail .

227

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

IrMail ) ASP.NET (


.
... .
IrMail ASP.NET
.
.
.
.
.
IrMail .
.
IrMail
Authentication
.NET ) Authentication(
. SMTP )(login

1
228

Ramin.samad@yahoo.com

ASP.NET

m.bashiry@gmail.com

Authenticate . IrMail .
username password Authentication .

.
UTF8AnyWhere UTF8
.
.

229

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

.
.
" "
!
IrMail .
SMTP ( SMTP
( . SMTP
Server .
.
:
- 1 XML . .NET
Linux . XML
.
- 2
. SMTP Server
(Not thread-safe).
.NET )
Thread ASP.NET ( . DBMS
.
230

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

IrMail
( Password Username
(... .
IrMail.Mail ) (Constructor
. )
VB.NET (.
Public Class MySmtpMail
Inherits IrMail.Mail
)(Public Sub New
) )""(MyBase.New(HttpContext.Current.Server.MapPath
IrMail.Mail
. .
) DB
fpdb (.
"Me.SMTPserver = "YourSMTPServer
"Me.PickUpDirectory = "c:\inetpub\mailroot\pickup
) (PickUpDirectory SMTP Server .

231

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

"Me.UserName = "YourUsername
"Me.Password = "YourPassword

Authentication . Authentication
.
Me.UTF8AnyWhere = True
.
false . false.
)Me.LoadSharedObject4WebApplication(HttpContext.Current
.
.
End Sub
End Class

. :
)( Dim ObjMailer As New MySmtpMail
"ObjMailer.From = "EveryOne@Server.Com
"ObjMailer.To= "EveryOne@AnotherServer.Com
"ObjMailer.Subject = "New Email Object
232

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

"ObjMailer.Body= "The body of your mail in each language


)(ObjMailer.Send
.
http://www27.brinkster.com/mahmoud690/irmail/sample.htm .
: IrMailMail.Send true .
false smtp server )
( . .
... : )! (Free And OpenSource
.
.
(OpenSource).

.NET

.
Opensource :
-


.
233

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

.
opensource . .
.NET Exe Dll !


.
debugger .
http://www27 .brinkster.com/mahmoud690 /irmail :
Download :
http://www27.brinkster.com/mahmoud690/irmail/downloadAssembly.htm.htm

Download :
http://www27.brinkster.com/mahmoud690/irmail/Download-source.htm

ASP.NET:
http://www.asp .net/ControlGallery/ControlDetail.aspx?Control=1918&tabindex=2

234

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET

ASP.NET
. Windows Authentication :

Forms-Based

Authentication .Passport Authentication


Iranasp.net Iranasp.net

.
www.iranasp.net/download/evalizadeh005.zip :
ASP.NET
. Forms-Based Authentication : Windows Authentication Passport
Authentication. Iranasp.net
Iranasp.net
http://www.iranasp.net/Members/postnews.aspx
. Login
Forms-Based Authentication .
Forms-Based Authentication
.

1
235

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET ( Visual Studio.NET): Visual Basic.NET


Web.config

Logon.aspx

default.aspx

236

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Microsoft Visual Studio .NET


Microsoft SQL Server
Microsoft Internet Information Server (IIS) version 5.0 or later
ASP.NET ( Visual Studio.NET): Visual Basic.NET
Visual Studio .NET -1 .
-2 ASP.NET Visual Basic.NET .
Web.config
> <authentication > <authorization
Web.config ASP.NET
. .
- 1 Web.config Project Explorer .
- 2 authentication " "Forms .
- 3 > <Forms )
QuickStart ( . authentication Web.config
. Edit Visual Studio.NET Paste as HTML
.

237

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

<authentication mode="Forms">
<forms name=".ASPXFORMSDEMO" loginUrl="logon.aspx"
protection="All" path="/" timeout="30" />
</authentication>

: authorization - 4
<authorization>
<deny users ="?" />
<allow users = "*" />
</authorization>


)(
.
. Notepad - 1
: SQL - 2
if exists (select * from sysobjects where id =
object_id(N'[dbo].[Users]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Users]
GO
238

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

CREATE TABLE [dbo].[Users] (


[uname] [varchar] (15) NOT NULL ,
[Pwd] [varchar] (25) NOT NULL ,
[userRole] [varchar] (25) NOT NULL ,
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Users] WITH NOCHECK ADD
CONSTRAINT [PK_Users] PRIMARY KEY NONCLUSTERED
(
[uname]
) ON [PRIMARY]
GO
INSERT INTO Users values('user1','user1','Manager')
INSERT INTO Users values('user2','user2','Admin')
INSERT INTO Users values('user3','user3','User')
GO
INSERT INTO Users values('user1','user1','Manager')
INSERT INTO Users values('user2','user2','Admin')
INSERT INTO Users values('user3','user3','User')
GO
. Users.sql - 3
) Query Analyzer Users.sql . - SQL Server 4
Databases .( SQL Server Tools Query Analyzer
239

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

Users . Users.sql) )Pubs


. ASP.NET Pubs
Connection String Pubs
. Pubs Connection
Logon.aspx
. Logon.aspx - 1
:< Form> Logon.aspx HTML - 2
<h3>
<font face="Verdana">Logon Page</font>
</h3>
<table>
<tr>
<td>UserName:</td>
<td><input id="txtUserName" type="text" runat="server"></td>
<td><ASP:RequiredFieldValidator ControlToValidate="txtUserName"
Display="Static" ErrorMessage="*" runat="server"
ID="vUserName" /></td>
</tr>
<tr>
<td>Password:</td>
<td><input id="txtUserPass" type="password" runat="server"></td>
<td><ASP:RequiredFieldValidator ControlToValidate="txtUserPass"
240

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

Display="Static" ErrorMessage="*" runat="server"


ID="vUserPass" />
</td>
</tr>
<tr>
<td>Persistent Cookie:</td>
<td><ASP:CheckBox id="chkPersistCookie" runat="server" autopostback="false"
/></td>
<td></td>
</tr>
</table>
<input type="submit" Value="Logon" runat="server" ID="cmdLogin"><p></p>
<asp:Label id="lblMsg" ForeColor="red" Font-Name="Verdana" Font-Size="10"
runat="server" />
. .

( Logon.aspx.vb Logon.aspx ) code-behind
.
. logon.aspx.vb - 1
: code-behind - 2

241

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

Imports System.Data.SqlClient
Imports System.Web.Security
ValidateUser - 3
. Connection String) .
.
.( Local SQL Server DOTNET
Function ValidateUser(uid As string, passwd As string) As Boolean
Dim cnn As SqlConnection
Dim cmd As SqlCommand
Dim dr As SqlDataReader
Dim retVal As Boolean = False
cnn = New SqlConnection("Integrated Security=SSPI;Persist Security
Info=False;Initial Catalog=pubs;Workstation

ID=DOTNET;")

cmd = New SqlCommand("Select * from users where uname = '" & uid & "'", cnn)
cnn.Open()
dr = cmd.ExecuteReader()
While (dr.Read())
If Strcomp(dr.Item("Pwd"), passwd, 1) = 0 Then
retVal = True
End If
End While
cnn.Close()
ValidateUser = retVal
End Function
242

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

- 4
. cmdLogin_ServerClick
:cmdLogin_ServerClick
RedirectFromLoginPage :
Private Sub cmdLogin_ServerClick(ByVal sender As Object, ByVal e As
System.EventArgs) _
Handles cmdLogin.ServerClick
If ValidateUser(txtUserName.Value,txtUserPass.value) Then
FormsAuthentication.RedirectFromLoginPage(txtUserName.Value, _
chkPersistCookie.Checked)
Else
lblMsg.Text = "Unknown User! try again."
End If
End Sub
.( authentication ticket) .
: .
Private Sub cmdLogin_ServerClick(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles cmdLogin.ServerClick
If Validateuser(txtUserName.Value,txtUserPass.Value) Then
Dim tkt As FormsAuthenticationTicket
243

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

Dim cookiestr As String


Dim ck As HttpCookie
tkt = New FormsAuthenticationTicket(1, txtUserName.Value, DateTime.Now(), _
dateTime.Now.AddMinutes(30), chkPersistCookie.Checked, "your custom data")
cookiestr = FormsAuthentication.Encrypt(tkt)
ck = new HttpCookie(FormsAuthentication.FormsCookieName(), cookiestr)
if (chkPersistCookie.Checked) then ck.Expires=tkt.Expiration
ck.Path = FormsAuthentication.FormsCookiePath()
Response.Cookies.Add(ck)
Dim strRedirect As String
strRedirect = Request("ReturnURL")
If strRedirect <> "" Then
Response.Redirect(strRedirect, True)
Else
strRedirect = "default.aspx"
Response.Redirect(strRedirect, True)
End If
Else
lblMsg.Text = "Unknown User! try again."
End If
End Sub

244

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

default.aspx
default.aspx .
.
logon.aspx .
- 1 default.aspx HTML .
> <Form :
>"<input type="submit" Value="SignOut" runat="server" id="cmdSignOut
) (log out default.aspx .
. .
- 2 code-behind default.aspx :
Imports System.Web.Security
- 3 cmdSignOut_ServerClick :
Private Sub cmdSignOut_ServerClick(ByVal sender As System.Object, ByVal e As
_ )System.EventArgs
Handles cmdSignOut.ServerClick
)(FormsAuthentication.SignOut
)Response.Redirect("logon.aspx", True
End Sub

245

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

- 4 . .

.


. HashPasswordForStoringInConfigFile
FormsAuthentication .
.
SQL Connection ) (Web.config
.

.



!
Secure Socket Layer
SSL .
246

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

.
< authentication> timeout
.


: ASP.NET
http://www.gotdot.NETcom/QuickStart/aspplus/default.aspx?url=/quickstart/aspplu
s/doc/formsauth.aspx
http://msdn.microsoft.com/library/enus/cpguidnf/html/cpconcookieauthenticationusinganxmlusersfile.asp
http://msdn.microsoft.com/library/default.asp?url=/library/enus/cpguide/html/cpconaspnetwebapplicationsecurity.asp
http://msdn.microsoft.com/library/dotnet/cpref/frlrfsystemwebsecurity.htm
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconaspnetconfiguration.asp
http://msdn.microsoft.com/library/default.asp?url=/library/enus/cpguide/html/cpgrfaspnetconfigurationsections.asp
http://msdn.microsoft.com/library/en-us/dnbda/html/authaspdot.NETasp

247

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET

.
... .

.
.
.
www.iranasp.net/download/ webtech047.zip :
iranasp .
1620 !
162 ) (
!! iranasp

1620
.
.

1
248

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com


.


.


! .
" " ! !

Page Navigation . Navigation
.
.
O .
)!( .


.
249

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

9 Next Prev
.
.
Next Prev .
IranASP.NET .


ASP.NET DataGrid

:
( DataGrid
.
( DataGrid
DataGrid
.


.

Cache .

250

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET Repeater
.
. .
. Repeater
DataGrid DataList .
ASP.NET
.

...

!
User Control
. HTML :

"<%@ Control Language="c#" AutoEventWireup="false


"Codebehind="PageNavigation.ascx.cs" Inherits="YourNamespace.PageNavigation
>TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %
><P
>"<TABLE cellSpacing="1" cellPadding="3" width="100%" border="0
><TR
>"<TD align="middle" dir="rtl
><asp:Label id="lblNav" runat="server"></asp:Label
></TD
251

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

></TR
></TABLE
></P

Label
. codebehind .
.
.
: CurrentPage .
.
: PageSize .
.
: TotalRecords .
.
: InitNav
.
:ShowNav .
:CssClass CSS .
252

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

: InActiveCssClass CSS
) "" (.

User Control . Visual Studio .NET
Solution Explorer drag-and-drop
. :
"<%@ Register TagPrefix="uc1" TagName="PageNavigation
>Src="PageNavigation.ascx" %
...
><uc1:PageNavigation id="pnPageNavigate" runat="server"></uc1:PageNavigation

PageSize CssClass InActiveCssClass


:
"<uc1:PageNavigation id="pnPageNavigate" PageSize="10" runat="server
"CssClass="yourclassname
>InActiveCssClass="anotherclassname"></uc1:PageNavigation

10 "" "" .
.
253

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

PageNavigation
.
:
;protected YourNamespace.PageNavigation pnPageNavigate
.
.
;)( this.pnPageNavigate.InitNav
DataSet ds = GetPagedAllNews (this.pnPageNavigate.CurrentPage ,
this.pnPageNavigate.PageSize,
;)out this.pnPageNavigate.TotalRecords
;this.repNews.DataSource = ds
;)(this.repNews.DataBind
;)(this.pnPageNavigate.ShowNav
InitNav ShowNav .
CurrentPage PageSize TotalRecords .
.
GetPagedAllNews . :
private DataSet GetPagedAllNews (int CurrentPage, int PageSize, out int
)TotalRecords
{
;)( DataSet ds = new DataSet
254

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

// Create Instance of Connection and Command Object


SqlConnection myConnection = new SqlConnection(ConnectionString);
SqlCommand myCommand = new SqlCommand("procGetPagedAllNews",
myConnection);
// Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure;
myCommand.Parameters.Add ("@CurrentPage", CurrentPage);
myCommand.Parameters.Add ("@PageSize", PageSize);
myCommand.Parameters.Add (new SqlParameter ("@TotalRecords",
SqlDbType.Int));
myCommand.Parameters ["@TotalRecords"].Direction = ParameterDirection.Output;
// Create a new SqlDataAdapter object for the News table
SqlDataAdapter da = new SqlDataAdapter(myCommand);
// Populate the ds with the data
da.Fill(ds);
TotalRecords = Convert.ToInt32 (myCommand.Parameters
["@TotalRecords"].Value);
return ds;
}

procGetPagedAllNews
.
News SQL Server .
:
255

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

NewsID int
NewsTitle nvarchar (256)

:
CREATE PROCEDURE dbo.procGetPagedAllNews
(
@CurrentPage int,
@PageSize int,
@TotalRecords int output
)
AS
SET NOCOUNT ON
--Create a temp table to hold the current page of data
--Add an ID column to count the records
CREATE TABLE #TempTable
(
ID int IDENTITY PRIMARY KEY,
NewsID int,
NewsTitle nvarchar (256),
)
--Fill the temp table with the News data
INSERT INTO #TempTable
(
256

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

NewsID,
NewsTitle,
)
SELECT NewsID, NewsTitle
FROM News
--Create variable to identify the first and last record that should be selected
DECLARE @FirstRec int, @LastRec int
SELECT @FirstRec = (@CurrentPage - 1) * @PageSize
SELECT @LastRec = (@CurrentPage * @PageSize + 1)
--Select one page of data based on the record numbers above
SELECT *
FROM
#TempTable
WHERE
ID > @FirstRec
AND
ID < @LastRec
--Return the total number of records available as an output parameter
SELECT @TotalRecords = COUNT(*) FROM #TempTable

ConnectionString
.

257

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

XML ) ASP.NET (

CNN news.com
asp aspx phphtml

.
:

XML .
JSP PHP ASP.NET ColdFusion
ASP.NET .
XML XSL
.



) (
Template ASP ASP.NET .
1
258

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

CNN news.com
< >
html asp aspx php jsp


ASP.NET PHP

.
.
.
)
( .

ASP.NET ASP
. ) (Render
.

259

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

) ) id
Template SQL .
URL article.aspx?id=102632 :
id 102632 ASP.NET
:
SELECT * FROM Articles WHERE ID=@id
:
><#% DataBinder.Eval( Container, DataItem.ArticleTitle ) %
Template .
) (102632
.


102632.htm .
server .

260

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com


article.aspx?id=102632

- 1 .

ASP.NET PHP HTML
.
.
Shared Hosting

.
Load -2 .

.
!

) (resources
. .
.
261

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

- 3 .

.
down
exception .
.
- 4 .

.

.
5

URL

article.aspx?id=102632&cat=214&sessionid=423442 )
( .
102632.htm
.
- 6 .
262

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com


. ) SQL
Server MySQL ORACLE DBMS ( .
x
)
( .
Host
!
- 7 Host .
HTML
web server .

.

upload .
) (
.

263

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

XML ) ASP.NET (

CNN news.com
asp aspx phphtml

.
www.iranasp .net/download/behrooznp002.zip :
XML ASP.NET
.
XML
.
ASP ASP.NET Template XSL
.
Template XHTML .
XHTML XSL .
HTMLXHTML

1
264

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

XHTML .
) ( HTML XHTML
XHTML . Dreamweaver
!
HTML HTML XHTML .
tag XML well-form
. XML tag . > <table></table
tag )> ( <br tag > </br .
XHTML .
XML .
XML . ; &nbsp
space XML space
. .
XHTML XML .
: utf-8 .
xml .

XHTMLXSL

265

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Template . XSL
. XSL
.
XSL
. XSL eXtensible Stylesheet Language . XSL
XML CSS HTML . CSS XSL
. CSS
XSL XML .
XSL XML XSLT
) XSL Transformation (.
:

XML. XSL tag .


> <"xsl:value-of select="ArticleTitle
ArticleTitle ASP.NET .
XSL syntax :

266

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

>"<xsl:for-each select="//Table
...
></xsl:for-each
Table .
xml
XML xslt XSL
HTML .!

ASP.NET
ASP.NET
publish .
ASP.NET HTML save
. ASP.NET
upload.
:
) VB.NET C# (

- 1 import:

267

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

Imports System.Text
Imports System.Data
Imports System.Data.SqlClient
Imports System.IO
Imports System.IO.Path
Imports System.Xml
Imports System.Xml.Xsl
datagrid - 2
. ASP.NET
ASP.NET
datagrid . datagrid
. ) ( select
.
J - 3
Function GenerateOneHTML(ByVal RecordID As Integer) As Boolean
'single node----------------------Dim myData As DataSet = GetDataSet()
Dim doc As XmlDataDocument = New XmlDataDocument(myData)
Dim FileName As String
Dim ln As Integer
Dim node As XmlElement = doc.DocumentElement.SelectSingleNode("//Table[ID="
+ RecordID.ToString + "]")
268

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

If Not node Is Nothing Then


Dim doc2 As XmlDocument = New XmlDocument
doc2.LoadXml(node.OuterXml)
'Generate HTML file name
FileName = RecordID.ToString
Dim HTMLsPath As String = Server.MapPath("\") + "Articles\" +
Trim(doc2.SelectSingleNode("//Category").InnerText) + "\"
'Transform
Dim xslt As XslTransform = New XslTransform
xslt.Load(HTMLsPath + "temp.html")
Dim writer As XmlTextWriter = New XmlTextWriter(HTMLsPath + FileName +
".htm", System.Text.Encoding.UTF8)
'writer.Formatting = Formatting.Indented
'writer.Indentation = 2
xslt.Transform(doc2, Nothing, writer, Nothing)
writer.Close()
End If
Return True
End Function
. )!( .

269

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com


.
.
:

- 1 xml dataset
- 2
- 3)(Tarnsform
XSLT .
XSLT !
:
dataset xml:
'single node----------------------)(Dim myData As DataSet = GetDataSet
)Dim doc As XmlDataDocument = New XmlDataDocument(myData
Dim FileName As String
Dim ln As Integer
Dim node As XmlElement = doc.DocumentElement.SelectSingleNode("//Table[ID=" +
)"]" RecordID.ToString +

270

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

dataset GetDataSet
. ADO.NET
) DataReader
(DataSet .
XmlDataDocument dataset XML .
XmlElement .
id input .
:
xml node.OuterXml XmlDocument
dataset ) if
(:
Dim doc2 As XmlDocument = New XmlDocument
)doc2.LoadXml(node.OuterXml
'Generate HTML file name
FileName = RecordID.ToString
Dim HTMLsPath As String = Server.MapPath("\") + "Articles\" +
"\" Trim(doc2.SelectSingleNode("//Category").InnerText) +

271

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Dim writer As XmlTextWriter = New XmlTextWriter(HTMLsPath + FileName +


)".htm", System.Text.Encoding.UTF8
'writer.Formatting = Formatting.Indented
'writer.Indentation = 2
)xslt.Transform(doc2, Nothing, writer, Nothing
)(writer.Close
:
- 1 XmlTextWriter.
- 2 XmlTextWriter .
- 3 property :
writer.Formatting = Formatting.Indented
writer.Indentation = 2
property . HTML
. XmlTextWriter HTML )!(
. HTML view
source !
Property HTML
) !( . Layout space
. . Property
273

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Indentation . 2 .
nesting HTML .
Transform . .
!
XmlTextWriter .

) .( id
datagrid checkbox
. id
. overwrite
. update.
Layout XSL .
. XSL htm html Dreamweaver
. XSL Transformation
.
:

. .
274

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

:
1 .

.

www.behrooznp.com/default.htm 1
275

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Setup .NET Crystal


1

Report

Visual
Studio .NET Setup .
Crystal Report .NET
. .
.NET Visual Studio.NET
. Setup
.NET Framework .
Crystal Report

Setup .
Setup :
Setup .
Setup Solution Explorer Add
Merge Module :
1
276

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

Crystal_Database_Access2003.msm
Crystal_Database_Access2003_enu.msm
Crystal_regwiz2003.msm
Properties Crystal_regwiz2003.msm Solution Explorer
.
License Key MergeModuleProperties Properties
.

:
Visual Studio .NET Help About Licence Key
Crystal Reports for Visual Studio .NET
.

277

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

.NET

m.bashiry@gmail.com

.NET
.
.
Microsoft .NET
. .

. .NET .NET
C# VB.NET
) VB Syntax
(.
.
VB.Net C# Windows Application :
-

VB MyvbProj .NET .

Solution Explorer Solution


Add New Project .

C# MycsProj .

1
278

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Solution Explorer Mycsproj


Properties .

Output Type Windows Application Class


Library .

Solution Explorer Solution


Solution Build .

Referencese Myvbproj
Referencese Add .

Projects Mycsproj Select


Ok .

VB C# Button
VB C# :

Dim Frm as new Mycsproj.Form1


)Frm.ShowDialog(Me

.

279

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Principle Generic
FormsAuthentication


.
ASP.NET .
FormsAuthentication .
WebApplication . Logon ! :
Web.Config -1 FormsAuthentication .
-2 Ticket
-3 GenericPrincipalFormsIdentity
-4
-1 Web.Config > <authentication :
><"authentication mode="Form
"<forms name="TestCookie " loginUrl= "login.aspx" protection="All" timeout="30

1
280

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

>path="/"></forms
></authentication
> <authorization > <authentication .
><authorization
><deny users="?" /
><allow users="*" /
></authorization
-2 Ticket
Ticket FormsAuthentication
.
) ( . .
Web.Config . Function :
Function IsAuthenticated(ByVal uid As String,ByVal pwd As String)As Boolean
...
Return true
End Function

. Function . :

281

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

Function GetRoles(ByVal uid As String,ByVal pwd As String)As Boolean


...
Return "Admin|Moderator|Manager"
End Function
: Button Logon.aspx
If dp.Authenticate(Trim(txtuid.Text), Trim(txtpwd.Text)) Then
Dim strRoles As String = dp.GetRoles(Trim(txtuid.Text) , Trim(txtpwd.Text))
Dim Roles() As String = Split(strroles,"|")
Dim authTicket As New FormsAuthenticationTicket(1, Trim(txtuid.Text), Now(),
Now.AddMinutes(60), False, Roles)
Dim encryptedTicket As String = FormsAuthentication.Encrypt(authTicket)
Dim authCookie As New HttpCookie(FormsAuthentication.FormsCookieName,
encryptedTicket)
Response.Cookies.Add(authCookie)
Response.Redirect(FormsAuthentication.GetRedirectUrl(Trim(txtuid.Text), False))
FormsIdentity GenericPrincipal -3
: Global.asax
Imports System.Web.Security
Imports System.Security.Principal
. Application_AuthenticateRequest

282

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

Dim cookieName As String = FormsAuthentication.FormsCookieName


Dim authCookie As HttpCookie = Context.Request.Cookies(cookieName)
If authCookie Is DBNull.Value Then
' There is no authentication cookie.
Return
End If
:
Dim authTicket As FormsAuthenticationTicket
Try
authTicket = FormsAuthentication.Decrypt(authCookie.Value)
Catch ex As Exception
Log exception details (omitted for simplicity)
Return
End Try
If authTicket Is DBNull.Value Then
Cookie failed to decrypt.
Return
End If
:
Dim roles As String() = authTicket.UserData.Split("|")
283

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

FormsIdentity
: Identity GenericPrincipal
' Create an Identity object
Dim id As New FormsIdentity(authTicket)
' This principal will flow throughout the request.
Dim principal As New GenericPrincipal(id, roles)
' Attach the new principal object to the current HttpContext object
Context.User = principal
: Test.aspx -5

Imports System.Security.Principal
: Load
Dim p As IPrincipal = HttpContext.Current.User
Response.Write("Authenticated Identity is: " + p.Identity.Name)
Response.Write("<p>")
If p.IsInRole("admin") Then
Response.Write("RoleName is: Admin")
End If

Building Secure Microsoft ASP.NET Applications


284

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET





.
) Static ) Dynamic



.
HTML .
Static Dynamic HTML Client
. Dynamic Server
.
ASP.NET . IIS
ASP.NET HTML
1
285

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Client .
HTML HTML Client.

. )
).1 ASP .JET Client
HTTP 1.1
.
.
HTTP 1.0
) 7 30(.
HTML Editor
.
.
Visual Basic.NET HTML Client

Client HTTP 1.0
.

www.softtool.info/aspjet/fa/default.htm 1
286

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com



.
HTTP 1.0 .
Tag
Tag
.
:
HttpResponse.Filter .
WhitespaceFilter
WhitespaceFilter.vb
Application_BeginRequest Global.asax :
Sub Application_BeginRequest(ByVal sender As Object,
)ByVal e As EventArgs
' Fires at the beginning of each request
Response.Filter = New
)WhitespaceFilter(Response.Filter
End Sub

287

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com


Load Global.asax
:
Sub Application_BeginRequest(ByVal sender As Object,
)ByVal e As EventArgs
' Fires upon attempting to authenticate the use
If
= )"Request.Url.PathAndQuery.ToLower.IndexOf("makethumbnail
-1 Then
Response.Filter = New
)WhitespaceFilter(Response.Filter
End If
End Sub
HTML
Editor NotePad
.
.
.
:WhitespaceFilter
288

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

: Class
Imports System.IO
Imports System.Text.RegularExpressions
:
' This filter gets rid of all unnecessary whitespace in
the output.

Public Class WhitespaceFilter


Inherits Stream

Private _sink As Stream


Private _position As Long

Public Sub New(ByVal sink As Stream)


_sink = sink
End Sub 'New

289

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

.
#Region " Code that will most likely never change from
filter to filter. "
. Stream
' The following members of Stream must be
overridden.
Public Overrides ReadOnly Property CanRead() As
Boolean
Get
Return True
End Get
End Property

Public Overrides ReadOnly Property CanSeek() As


Boolean
Get
Return True
End Get
290

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

End Property

Public Overrides ReadOnly Property CanWrite() As


Boolean
Get
Return True
End Get
End Property

Public Overrides ReadOnly Property Length() As Long


Get
Return 0
End Get
End Property

Public Overrides Property Position() As Long


Get
Return _position
291

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

End Get
Set(ByVal Value As Long)
_position = Value
End Set
End Property

Public Overrides Function Seek(ByVal offset As


Long, ByVal direction As System.IO.SeekOrigin) As Long
Return _sink.Seek(offset, direction)
End Function 'Seek

Public Overrides Sub SetLength(ByVal length As


Long)
_sink.SetLength(length)
End Sub 'SetLength

Public Overrides Sub Close()


_sink.Close()
292

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

End Sub 'Close

Public Overrides Sub Flush()


_sink.Flush()
End Sub 'Flush

Public Overrides Function Read(ByVal MyBuffer() As


Byte, ByVal offset As Integer, ByVal count As Integer) As
Integer
_sink.Read(MyBuffer, offset, count)
End Function

#End Region
. Write
' Write is the method that actually does the
filtering.

293

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

Public Overrides Sub Write(ByVal MyBuffer() As


Byte, ByVal offset As Integer, ByVal count As Integer)
Dim data(count) As Byte
Buffer.BlockCopy(MyBuffer, offset, data, 0,
count)
UTF-8 IDE ASCII Encoding
. B ASCII Encoding
' Don't use ASCII encoding here.

The .NET IDE

replaces some characters, such as &reg;


' with a UTF-8 entity.

If you use ASCII

encoding, you'll get B. instead of the registered


' trademark symbol.
Dim s As String =
System.Text.Encoding.UTF8.GetString(data)
.
Java Script Semi-colon
.
.

294

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

' Replace control characters with either spaces


or nothing

' The funky semi-colon handling is there


because of a JavaScript comment in a component.
' This way, we keep the carriage returns that
actually matter.
s = s.Replace(ControlChars.Cr,
Chr(255)).Replace(ControlChars.Lf,
"").Replace(ControlChars.Tab, "")
s = s.Replace(";" & Chr(255), ";" &
ControlChars.Cr)
s = s.Replace(Chr(255), " ")

' Eliminate excess whitespace.
Do
s = s.Replace("

", " ")

Loop Until s.IndexOf("

") = -1
.

295

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

.
.
.
' Eliminate known comments.

' We use three comments in our template.

These

comments go on every single page on the site.


' Obviously, we can kill them when they are
going out.

This way, the comments stay in for


' maintenance, but are trimmed before release.
s = s.Replace("<!-- Page Content Goes Above

Here -->", "")


s = s.Replace("<!-- Page Content Goes Below
Here -->", "")
s = s.Replace("<!-- Do not get rid of this
&nbsp; on data pages -->", "")
.
. DOCTYPE
' Eliminate some additional whitespace we can
kill
296

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

' For some reason, a single space gets emitted


before each of our DOCTYPE directives.
s = s.Replace(" <!DOCTYPE", "<!DOCTYPE")
:
' These are the most common excess whitespace items
we can remove.
s = s.Replace("<li> ", "<li>").Replace("</td> ",
"</td>").Replace("</tr> ", "</tr>").Replace("</ul> ",
"</ul>").Replace("</table> ", "</table>").Replace("</li> ",
"</li>")
s = s.Replace("<LI> ", "<LI>").Replace("</TD> ",
"</TD>").Replace("</TR> ", "</TR>").Replace("</UL> ",
"</UL>").Replace("</TABLE> ", "</TABLE>").Replace("</LI> ",
"</LI>")
s = s.Replace("<td> ", "<td>").Replace("<tr> ",
"<tr>")
s = s.Replace("<TD> ", "<TD>").Replace("<TR> ",
"<TR>")
s = s.Replace("<P> ", "<P>").Replace("<p> ", "<p>")
s = s.Replace("</P> ", "</P>").Replace("</p> ",
"</p>")
297

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

s = s.Replace("style=""display:inline""> ",
"style=""display:inline"">")
s = s.Replace(" <H", "<H").Replace(" <h",
"<h").Replace(" </H", "</H").Replace(" </h", "</h")
s = s.Replace("<UL> ", "<UL>").Replace("<ul> ",
"<ul>")
s = s.Replace(" <TABLE", "<TABLE").Replace("
<table", "<table")
s = s.Replace(" <li>", "<li>").Replace(" <LI>",
"<LI>")
s = s.Replace(" <br>", "<br>").Replace(" <BR>",
"<BR>").Replace("<br> ", "<br>").Replace("<BR> ", "<BR>")
s = s.Replace(" <ul>", "<ul>").Replace(" <UL>",
"<UL>")

: Tag
' Replace long tags with short ones
s = s.Replace("<STRONG>",
"<B>").Replace("<strong>", "<b>")
s = s.Replace("</STRONG>",
"</B>").Replace("</strong>", "</b>")
: HTML
298

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

' Replace some HTML entities with true


character codes
s = s.Replace("&brkbar;", "|")
s = s.Replace("&brvbar;", "|")
s = s.Replace("&shy;", "-")
s = s.Replace("&nbsp;", Chr(160))
s = s.Replace("&lsquor;", "'")
s = s.Replace("&ldquor;", """")
s = s.Replace("&lsquo;", "'")
s = s.Replace("&rsquor;", "'")
s = s.Replace("&rsquo;", "'")
s = s.Replace("&ldquo;", """")
s = s.Replace("&rdquor;", """")
s = s.Replace("&rdquo;", """")
s = s.Replace("&ndash;", "-")
s = s.Replace("&endash;", "-")
: JavaScript

299

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

' If we don't do this, JavaScript horks on the


site
s = s.Replace("<!--", "<!--" & ControlChars.Cr)
s = s.Replace("}", "}" & ControlChars.Cr)
:
' Last chance to eliminate excess whitespace
Do
s = s.Replace("

", " ")

Loop Until s.IndexOf("

") = -1

:
' Finally, we spit out what we have done.
Dim outdata() As Byte =
System.Text.Encoding.UTF8.GetBytes(s)
_sink.Write(outdata, 0, outdata.GetLength(0))

End Sub 'Write

300

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

End Class
http://www.codeproject.com/aspnet/ WhitespaceFilter.asp:

301

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

RSS

. RSS RSS
XML Really Simple Syndication
.
. ASP.NET RSS
RSS
. XML RSS
. RSS
<rss version="2.0">
<channel xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<title>IranASP.NET New Articles RSS Feed</title>
<language>fa-IR</language>
<copyright>(c) 2004 by IranASP.NET</copyright>
<pubDate>Sun, 08 Aug 2004 06:11:37 GMT</pubDate>
<lastBuildDate>Sun, 08 Aug 2004 06:11:37 GMT</lastBuildDate>
<generator>IranASP.NET rss generator</generator>
<item>
ASP.NET</title>

<title>

1
302

Ramin.samad@yahoo.com

m.bashiry@gmail.com

ASP.NET

<link>http://www.iranasp.net/articles/showarticle.aspx?articleid=154</link>
<pubDate>Sun, 25 Jul 2004 19:30:00 GMT</pubDate>
</item>
</channel>
</rss>


: <rss>

303

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

>:<title .
>:<link URL .
>:<description .
>:<pubDate .
Sun, 25 Jul 2004 12:00:00 GMT .

RSS
RSS . RSS
XML . RSS XML
Text writer . .
.
VS.NET . > <item XML
. ) (properties )(methods
:

)(properties
:Outputstream ) ( Stream .
304

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

. < channel> < title> :RssTitle


. < channel> < link> :PublisherUrl
. < channel> < description> :Description
. < channel> < copyright> :Copyright
. < channel> < generator> :Generator
. :ItemSource
<item> < title> ) ( Datacolumn ItemTitleField
.
. < item> < link> Datacolumn :ItemURLField
< item> < description> Datacolumn :ItemDescriptionField
.
< item> < pubDate> Datacolumn :ItemPublicationDateField
.

. Outputstream RSS :PublishRss


305

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

properties RSS
. ( Public )
Public Class Rss
Public OutputStream As Stream
Public RssTitle As String
Public PublisherUrl As String
Public Description As String
Public Copyright As String
Public Generator As String
Public ItemSource As DataSet
Public ItemTitleField As String
Public ItemUrlField As String
Public ItemDescriptionField As String
Public ItemPublicationDateField As String
Public Shared Function PublishRss(ByVal r As Rss)
Dim writer As New XmlTextWriter(r.OutputStream,
System.Text.Encoding.ASCII)
writer.WriteStartElement("rss")
writer.WriteAttributeString("version", "2.0")
writer.WriteStartElement("channel")
writer.WriteElementString("title", r.RssTitle)
writer.WriteElementString("link", r.PublisherUrl)
writer.WriteElementString("description", r.Description)
writer.WriteElementString("copyright", r.Copyright)
writer.WriteElementString("generator", r.Generator
306

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

For Each row As DataRow In r.ItemSource.Tables(0).Rows


writer.WriteStartElement("item")
writer.WriteElementString("title", row(r.ItemTitleField))
writer.WriteElementString("link", row(r.ItemUrlField))
writer.WriteElementString("description",
row(r.ItemDescriptionField))
writer.WriteElementString("pubDate",
CType(row(r.ItemPublicationDateField),
DateTime).ToString("ddd, dd MMM yyyy 12:00:00 tt G\MT"))
writer.WriteEndElement()
Next
writer.WriteEndElement()
writer.WriteEndElement()
writer.Flush()
End Function
End Class
. PublishRss
. XML . System.XML.XmlTextwriter
ASCII . encoding OutputStream
XmlTextwriter . RSS .
:
) :WritestartElement
.(< channel/> < channel>
307

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

:WriteAttributeString .
:WriteElementString .
:WriteEndElement .
.
:Flush .
WriteStartElement WriteEndElement
.
ASP.NET
.
.
RSS .
)Article_ title - Varchar (255
)Article_ Description -Varchar (1000
)Article_ url - Varchar (255
Article_ pubdate - DateTime
GetDataSet
RSS . DataAdapter :

308

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

Function GetDataSet() as DataSet


Dim cnn as New SqlConnection("connection string here")
sql = "select * from sometable order by Article_pubdate desc"
Dim da As New SqlDataAdapter(sql,cnn)
Dim ds as New DataSet()
da.Fill(ds,"MyArticles")
Return ds
End Function
Rss RSS
. GetDataSet
. Rss ItemSource
. ContentType ContentEncoding response
Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
Dim r As New Rss
Dim ds As DataSet = GetDataSet()
r.OutputStream = Response.OutputStream
r.RssTitle = "DotNetBips.com Latest Articles"
r.PublisherUrl = Request.Url.Host
r.Description = "DotNetBips.com - Applying.NET"
r.Copyright = "Copyright (C) DotNetBips.com."
r.Generator = "DotNetBips.com RSS Generator"
r.ItemSource = ds
r.ItemTitleField = "Article_title"
309

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

r.ItemDescriptionField = "Article_Description"
r.ItemPublicationDateField = "Article_pubdate"
r.ItemUrlField = "Article_url"
Response.ContentEncoding = System.Text.Encoding.UTF8
Response.ContentType = "text/xml"
Rss.PublishRss(r)
Response.End()
End Sub
. Rss PublishRss
. RSS XML !
http://www.dotnetbips.com:

310

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET 1.x - ASP.NET 2.0

ASP.NET 1,0 1,1 .




.NET ASP.NET .
ASP.NET 2.0 2005 .


. ASP.NET
. .NET
.
ASP.NET 1,0 1,1 2002 2003

.NET ASP.NET .
Visual Studio .NET Whidbey 2004 .

1
311

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com



. :
) ( !!!
!!
.
MSDN
.
ASP.NET 2.0
ASP.NET 2.0 :
- 1 Web
Microsoft Information Services (IIS) 5.0
. ASP.NET 2.0 IIS 6.0
.
.
. .
.
312

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

- 2
ASP.NET 2.0 Wizard
) (
- 3 Web
ASP.NET 2.0 Account
. .
Login Account Login
.
- 4
ASP.NET 2.0 Master PageTheme Skin
.
.

ASP.NET 1.x
ASP.NET 1.x ASP.NET
2.0 ASP.NET 1.x . ASP.NET

313

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

1.x ASP.NET 2.0


ASP.NET 2.0 .

ASP.NET . ASP.NET 2.0
Provider . Utility
API .
ASP.NET 2.0 .
Provider
ASP.NET 2.0 Web
ASP.NET 2.0
.
Provider ASP.NET 2.0
.
.
Method :
ASP.NET 2.0 Providers

314

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Provider
ASP.NET . Provider
:
:Membership .
:Profile Profile .
:Personalization Provider
.
:Site Navigation Provider ASP.NET
.
:Data Provider ADO.NET Provider Database
) ( API . ASP.NET 2.0
.NET ADO.NET .
Provider Provider
Profile Profile Membership .
ASP.NET 2.0 .
ASP.NET 2.0

315

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET 1.x ASP.NET :


HTML ) (Code Inline
Code Behind .
HTML
.
Code Behind ASPX
HTML Tag .
. ASP.NET 2.0
.
Code Inline
Visual Studio 2005 Code
Behind > <Script ASPX
Code Behind . Visual Studio 2005
Visual Studio
ASPX .

316

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

> <Script
. .
Code Behind
ASPX
Check Box .

317

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Code Behind ASP.NET 1.x ASP.NET 2.0 Code


Behind Partial Class Class . Partial Class
NET . .
ASP.NET 2.0 Partial Class Code Behind
Inherit Behind Code .

318

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

Compile ASPX Code Behind Partial Class


Code Code Behind
Code Behind . Behind

Initialization Code Behind .
:
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
private void Page_Load(object sender, System.EventArgs e) { }
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
void Page_Load(object sender, EventArgs e)
{
Label1.Text = "Hello ASP.NET 2.0";
319

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

}
}
ASPX :
{ namespace ASP
public partial class Webform1_aspx
{
)void Page_Load(object sender, EventArgs e
{
;"Label1.Text = "Hello ASP.NET 2.0
}
}
}
Code Behind . Code Behind
ASP.NET .
/Code directory
ASP.NET .
Web .
Reference Web.

320

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Reference ) (Name Space


.
.
ASP.NET 2.0 Directory
/Code
ASP.NET . Directory
ASPX .
Visual Studio .NET 2005 ASP.NET
.

ASP.NET Web.Config
Case Sensitive ASP.NET 2.0 Visual Studio .NET 2005
.
IntellisenseWeb.Config
Intellisense . Visual
.

321

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Intellisense XML
. Web.Config Intellisense
Visual Studio .

Intellisense .
ASP.NET 2.0 Administrative Web site
.
Administrative Web site
ASP.NET 2.0
Local host
Administrator
Profile .
Trace .
322

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

API
API . System.Configuration.Configuration
. XML
Local Authentication .
: Machine
[C#]
Configuration cfg = Configuration.GetConfigurationForUrl("/Application_name");
Response.Write( cfg.Web.Authentication.Mode.ToString() );
[VB.NET]
Dim cfg As Configuration =
Configuration.GetConfigurationForUrl("/Application_name")
Response.Write( cfg.Web.Authentication.Mode.ToString() )
: authentication Forms-Based
[C#]
Configuration cfg = Configuration.GetConfigurationForUrl("/MyApp");
cfg.Web.Authentication.Mode = HttpAuthenticationMode.Forms;
cfg.Update();
[VB.NET]
Dim cfg As Configuration = & _

324

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

)"Configuration.GetConfigurationForUrl("/MyApp
)(cfg.Web.Authentication.Mode = HttpAuthenticationMode.Forms cfg.Update

.
Development
ASP.NET 2.0 Visual Studio 2005
.
ASP.NET 1.x .
Server
ASP.NET 1.x Visual Studio .NET IIS
Microsoft FrontPage Server Extensions .
IIS
:
The Development Server
Visual Studio .NET 2005 Server Web
Server . .
Server

325

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

.
IIS .
The Production Server
IIS .
Visual Studio .NET Connection .

Share Point FTP Microsoft FrontPage Server Extensions


Server .
ASP.NET 2.0

326

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET 1.x
. ASP.NET 1.x Batch Start Up
. . Server
.
ASP.NET 2.0 Pre-Compile
) (deployment
.
Pre-Compile ASP.NET.

327

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET 1.x - ASP.NET 2.0

ASP.NET 1,0 1,1 .




.NET ASP.NET .
ASP.NET 2.0 2005 .

Navigation
ASP.NET 1.x
HyperLink
.
. ASP.NET 1.x
HTML . ASP.NET 2.0
Navigation
.
ASP.NET 2.0 (Logical
)Structure . Navigation
1
328

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Navigation
.
. Navigation
Menu Tree View ... .
Web.SiteMap
SiteMap ASP.NET 2.0 .
XML Navigation ASP.NET 2.0
.
Navigation . (Logical
)Structure :
- 1 XML Web.SiteMap
. Visual Studio.NET 2005
Site. Add New Item SiteMap
Intellisense .
>? "<?xml version="1.0" encoding="utf-8
><siteMap
>"<siteMapNode title="Home" url="default.aspx
><siteMapNode title="Article 1" url="~/articles/demoarticle1.aspx" /
><siteMapNode title="Article 2" url="~/articles/demoarticle2.aspx" /
><siteMapNode title="Article 3" url="~/articles/demoarticle3.aspx" /
329

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

</siteMapNode>
<siteMapNode title="Picture Gallery" url="~/PhotoAlbum/PhotoAlbums.aspx">
<siteMapNode title=
"Meetings"url="~/PhotoAlbum/PictureAlbum.aspx?albumid=1"/>
<siteMapNodetitle="Activities"url="~/PhotoAlbum/PictureAlbum.aspx?albumid=2
"/>
<siteMapNode title=
"Training"url="~/PhotoAlbum/PictureAlbum.aspx?albumid=3"/>
</siteMapNode>
</siteMap>
(Drap & Drown ToolBox SiteMap DataSource - 2
Web.SiteMap .(
Tree SiteMap DataSource
. Menu View
<%@ page language="VB" master="~/Mysite.master" %>
<asp:content id="Content1" contentplaceholderid="LeftSideContent">
<H2>Navigation </h2>
<asp:treeview id="Navigation tree" runat="server" datasourceid="NavSource"/>
</asp:content>
Navigation
Navigation Navigation ASP.NET 2.0
< asp:TreeView> < asp:Menu> .
330

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Navigation . > <asp:SiteMapPath


Navigation Bread Crum Trail .

URL
ASP.NET 2.0 Navigation URL .
URL ) URL MSDN !!( . URL
ASP ISAPI Handler
. ASP.NET 2.0 URL Mapping Web.Config
URL URL
.
>"<urlMappings enabled="true
><add url= "~/Home.aspx"mappedUrl="~/Default.aspx?tabid=0" /
></urlMappings
Home.aspx )
(Redirect Default.aspx?tabid=0

331

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET 1.x Connection Command


ASP.NET .
ASP.NET 2.0 ADO.NET
Connection Command XML Web.Config .
ASP.NET 1.x Wizard Visual Studio 2005
. ASP.NET 2.0 :
:Microsoft Access Access Access
Query .
):(Objects ObjectDataSource
.
.
:DataSet DataSetDataSource
XML .
:XML XMLDataSource XML .
XMLDataSource DataSetDataSource XMLDataSource
TreeView . DataSetDataSource
DataGrid .

332

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

: SiteMapDataSource Navigation
.

ASP.NET 2.0 . GridView
DataGrid
.

DetailsView GridView DataGrid


.

333

Ramin.samad@yahoo.com

m.bashiry@gmail.com

ASP.NET

DetailView

334

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com


ASP.NET 2.0 .
Master Pages
.
.
Master Pages .

. Visual Inheritance
Microsoft Windows.
Master Page ASP.NET )
.master ( .aspx . Master Pages
> <asp:ContentPlaceHolder .
. ContenetPlaceHolder .
Visual Studio 2005
HTML . Master Page :
"<%@ master language="C#" compilewith="site.master.cs
>classname="ASP.site_master" %
><html
><head runat="server"><title>Untitled Page</title></head
335

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

><body
>"<form runat="server
>"<asp:contentplaceholder id="ContentPlaceHolder1" runat="server
></asp:contentplaceholder
></form
></body
></html
Master Page
ASP.NET .
Master Page Frame Master Page
. Frame Master Page .
- 1 .
Master Page Frame
.
- 2 HTML
Frame . Visual Studio .
- 3 Master Pages.
HTML .
Master Page
.
336

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

)(Content Pages
Master Page ContentPlaceHolder
Master Page . > <asp:content
><asp:contentPlaceHolder Master Page ContentPlaceHolder ID .
Master Page .
><%@ page language="VB" master="~/Mysite.master" %
>"<asp:content id="Content1" contentplaceholderid="LeftSideContent
><H2>Navigation </h2
><asp:treeview id="Navigation tree" runat="server" datasourceid="NavSource"/
></asp:content
>"<asp:content id="Content1" contentplaceholderid="RightSideContent
><asp:label runat="server">Support section</asp:label
></asp:content
: ASP.NET
Master Page .

Master Page
Master Page .

IT .
337

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Master Page Master Page


.

Master Page .

Master Page
Master Page
.
.
Master Page ) (Public
Master Page .

338

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

HTML < head> < keyword> < title>


: Master Page
<head runat="server" id="Head1">
<title><% =m_HtmlTitle %></title>
<meta name="keywords" content="<% =GetKeywords() %>" >
<meta name="description" content="A newsletter focused on meeting the needs of
.NET developers, providing cool tips for the advanced programmer, and keeping you
informed on what's happening with .NET!" >
<LINK href="<% =Request.ApplicationPath %>/portal.css" type="text/css"
rel="stylesheet">
</head>

SkinsThemes
CSS
. . CSS
. ASP.NET 2.0

Themes
CSS Style Theme
: Style Sheet Theme
339

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Theme -1 Style
.
Theme -2 CSS Style .
Theme -3 Style Sheet .
Theme -4 Refrence Style Sheet .
Themes . Theme
Skin .

Theme
Theme Skin Themes
. Theme . skins.
Theme Style Sheet .

340

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

Skin. Skin
. Pink Themes . ASPX
: Pink Theme skin.
<asp:DropDownList runat="server" BackColor="hotpink" ForeColor="white" />
<asp:DataGrid runat="server" BackColor="#CCCCCC" BorderWidth="2pt"
BorderStyle="Solid" BorderColor="#CCCCCC" GridLines="Vertical"
HorizontalAlign="Left">
<HeaderStyle ForeColor="white" BackColor="hotpink" />
<ItemStyle ForeColor="black" BackColor="white" />
<AlternatingItemStyle BackColor="pink" ForeColor="black" />
</asp:DataGrid>
. Theme
. Data Grid

Theme
: Theme
<% "page language="VB" theme="Pink @%> - 1
</"pages theme="Pink> Web.config - 2

341

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Web.Config . Theme
.

342

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Skins
Skin
. Skin
. Skin
SkinID .
>!><!- Default Skin --
=<asp: label runat="server" Font-names="verdana, arial" font-size="10pt" ForeColor
>"#000066" BackColor="transparent"/
>!><!- Title Skin --
<asp: label runat="server" id="foo" skinid="Title" Font-names="verdana, arial" font
size="18pt" ForeColor= "#000066" BackColor="transparent" font-bold="true" font>underline="true"/
Skin SkinID
.

Skin
Skin Theme Skin
. SkinID Skin
Skin SkinID .
.
343

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

)(User Membership
ASP .
. Login
.

. .
Microsoft Access Microsoft SQL Server .
Web.Config .
Login ASP.NET 2.0 .

Login
ASP.NET 2.0 Login
.
><asp:CreateUserWizard
.

. Label Value Error message validation

344

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

. LoginName LoginStatus
.
LoginView
) ( . .
ASP
.
Profile
Profile ASP.NET 2.0
. ASP
session
. Profile Profile ASPX .

Profile
Wen.Config Machine.Config > <property
Profile ... .
><profile
>"<group name="BillingAddress
><add name="Street" type="System.String" /
345

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

><add name="City" defaultValue="Toronto" type="System.String" /


><add name="StateProv" type="System.String" /
><add name="ZipPostal" type="System.String" /
></group
></profile
ASP.NET 2.0 .

Profile
Profile Visual Studio 2005
Profile .

Visual Studio 2005 Intellisense Profile .


Profile Visual Studio Intellisense
Web.Config .
346

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET

: ASP.NET
ASP.NET .

. .
ASP.NET! .
. ASP.NET
.
ASP.NET .
.
.
ASP.NET
.


ASP.NET .
ASP.NET .
1
347

Ramin.samad@yahoo.com

ASP.NET

348

m.bashiry@gmail.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

.
.
.
.

.
. IranASP.NET
.
. !

.
.
.

.
.

. .

349

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

.
ASP.NET !
.

!

.
.
Reading .
.
.
. .
.

.
.
.
.
350

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com


.
.
.
. .
ASP.NET ADO.NET
. .

ASP.NET
. ASP.NET
. .
ASP.NET .
. .

. . C++ Visual Basic . SQL . . Visual .351

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

IIS Virtual Directory . - . .- ...


- !

ASP.NET
. .
. ASP.NET
:
.
. .
. . .
.
.
.
! .
.
352

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

. .
: . . .
ASP.NET .

353

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

- ASP.NET

ASP.NET ASP.NET
Client .
Event Log .
)(Customize

)(Event Log

ASP.NET Client .
:

(Configuration errors): Web.config


)(Configuration .
(Parser errors): Syntax ASP.NET
.
(Compilation errors): )(Statements
)(Language .

1
354

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

(Run-time errors):
.

) ( .
ASP.NET .
. :
><%@ Page Debug="true" %
Web.config
.
><configuration
><system.web
><compilation debug="true"/
></system.web
></configuration
: .
.

.
)(Development ASP.NET
355

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

.
client )(Local
ASP.NET (client ( . client
.
Web.config :
><configuration
><system.web
><customErrors defaultRedirect="genericerror.htm" mode="RemoteOnly" /
></system.web
></configuration
client ASP.NET
client )(Remote genericerror.htm .
.aspx .ASP.NET
QueryString .
client )(Remote .
><%@ Page Language="C#" Description="Error page"%
><html
><head
><title>Error page</title
></head
356

Ramin.samad@yahoo.com

ASP.NET

m.bashiry@gmail.com

><body
><h1>Error page</h1
>Error originated on: <%=Request.QueryString["ErrorPage"] %
></body
></html

: aspnet_isapi.dll IIS .
aspnet_isapi.dll ASP.NET IIS .
)(Configuration IIS IIS .
attribute > <customErrors .

Attribute

mode

)(Remote .
) RemoteOnlyOff On : (.

357

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

client client Mode


. .
Remote host request

Local host request

Mode

On

ASP.NET .

ASP.NET .

Off

ASP.NET .

RemoteOnly

.< customErrors>
[Web.config]
<configuration>
<system.web>
<customErrors defaultRedirect="genericerror.htm" mode="On"/>
</system.web>
</configuration>

[Genericeroor.htm'
<html>
<head>
<title>An Error Has Occured</title>
</head>
<body bgcolor="beige">
358

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

<font face="verdana">
<h4>We're Sorry...</h4>
An error has occured on the page you were requesting. If this problem persists,
please contact the site administrator.
<p>
<hr>
</font>
</body>
</html>

[Custom1.aspx]
<html>
<script language="C#" runat="server">
void Error_500(Object sender, EventArgs e) {
String foo = null;
Response.Write(foo.ToString());
}
</script>
<body>
<form runat="server">
<h4><font face="verdana">Cause an Error to Occur...</font></h4>
<asp:button text="500 Server Error" OnClick="Error_500" width="150"
359

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

runat="server"/><p>
</form>
</body>
</html>

HTTP < error> < customErrors> .
: .
<configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="/genericerror.htm">
<error statusCode="500" redirect="/error/callsupport.htm"/>
<error statusCode="404" redirect="/error/notfound.aspx"/>
<error statusCode="403" redirect="/error/noaccess.aspx"/>
</customErrors>
</system.web>
</configuration>
.< error> attribute
Attribute
:. HTTP StatusCode

.Internal Server Error 500 Forbidden 404 Not Found 403


360

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

. client Redirect
aspx .< error>
QueryString " File Not Found"
.
[Custom2.aspx]
<html>
<script language="C#" runat="server">
void Error_404(Object sender, EventArgs e) {
Response.Redirect("nowhere.aspx");
}
void Error_500(Object sender, EventArgs e) {
String foo = null;
Response.Write(foo.ToString());
}
</script>
<body>
<form runat="server">
<h4><font face="verdana">Cause an Error to Occur...</font></h4>
<asp:button text="404 Not Found" OnClick="Error_404" width="150"
361

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

runat="server"/><p>
<asp:button text="500 Server Error" OnClick="Error_500" width="150"
runat="server"/><p>
</form>
</body>
</html>

[Notfound.aspx]
<%@ Page Language="C#" %>
<html>
<head>
<title>An Error Has Occured</title>
</head>
<body bgcolor="ccffcc">
<font face="verdana">
<h4>We could not locate the page you requested...</h4>
<% if ( Request.QueryString["aspxerrorpath"] != null ) { %>
<%=HttpUtility.HtmlEncode(Request.QueryString["aspxerrorpath"])%>
<% } %>
<p>
Perhaps you mis-typed the URL? Please try again, or visit our search page for help.
<p>
<hr>
</font>
362

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

</body>
</html>

[Web.config]
<configuration>
<system.web>
<customErrors defaultRedirect="genericerror.htm" mode="On">
<error statusCode="404" redirect="notfound.aspx"/>
</customErrors>
</system.web>
</configuration>

363

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

- ASP.NET

ASP.NET ASP.NET
Client .
Event Log .


. Page
Page_Error override .
.
>"<script language="C#" runat="server
{ )void Page_Error(Object source, EventArgs e
">String message = "<font face=verdana color=red
">+ "<h4>" + Request.Url.ToString() + "</h4
">'+ "<pre><font color='red
">+ Server.GetLastError().ToString() + "</pre
;">+ "</font
;)Response.Write(message

1
364

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

}
</script>
. Page_Error
[error2.aspx]
<html>
<script language="C#" runat="server">
void Error_500(Object sender, EventArgs e) {
String foo = null;
Response.Write(foo.ToString());
}
void Page_Error(Object sender, EventArgs e) {
String message = "<font face=verdana color=red>"
+ "<h4>" + Request.Url.ToString() + "</h4>"
+ "<pre><font color='red'>" + Server.GetLastError().ToString() + "</pre>"
+ "</font>";
Response.Write(message);
Server.ClearError();
}
</script>
365

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

<body>
<form runat="server">
<h4><font face="verdana">Cause an Error to Occur...</font></h4>
<asp:button text="500 Server Error" OnClick="Error_500" width="150"
runat="server"/><p>
</form>
</body>
</html>

. System.Web.Mail .ASP.NET
:@ Import
<%@ Import Namespace="System.Web.Mail" %>
. SmtpMail MailMessage
MailMessage mail = new MailMessage();
mail.From = "automated@www.contoso.com";
mail.To = "administrator@www.contoso.com";
mail.Subject = "Site Error";
mail.Body = message;
mail.BodyFormat = MailFormat.Html;
SmtpMail.Send(mail);

366

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

.
Mail SMTP :
. IIS Mail SMTP .
[error3.aspx]
<%@ Import Namespace="System.Web.Mail" %>
<html>
<script language="VB" runat="server">
Sub Error_500(sender As Object, e As EventArgs)
Dim foo As String = Nothing
Response.Write(foo.ToString())
End Sub
Sub Page_Error(Sender As Object, E As EventArgs)
Dim message As String = "<font face=verdana color=red>" _
& "<h4>" & Request.Url.ToString() & "</h4>" _
& "<pre><font color=red>" & Server.GetLastError().ToString() & "</pre>" _
& "</font>"
Response.Write(message)
Response.Write("An error has occured on this server, and the administrator of the
site has been notified.")
367

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

Dim mail As New MailMessage


"automated@www.contoso.com

mail.From = "

"administrator@www.contoso.com

mail.To = "

mail.Subject = "Site Error"


mail.Body = message
mail.BodyFormat = MailFormat.Html
SmtpMail.Send(mail)
Server.ClearError()
End Sub
</script>
<body>
<form runat="server">
<h4><font face="verdana">Cause an Error to Occur...</font></h4>
<asp:button text="500 Server Error" OnClick="Error_500" width="150"
runat="server"/><p>
</form>
</body>
</html>
.
. Global.asax Application_Error
.
368

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

void Application_Error(Object sender, EventArgs e) {


//...Do something here
}
(Event Log)
. System.Diagnostics
:
<%@ Import Namespace="System.Diagnostics"%>
. EventLog
.
. Global.asax Application_Error
.
void Application_Error(Object sender, EventArgs e) {
String Message = "\n\nURL:\n http://localhost/" + Request.Path
+ "\n\nMESSAGE:\n " + Server.GetLastError().Message
+ "\n\nSTACK TRACE:\n" + Server.GetLastError().StackTrace;
// Create event Log if it does not exist
String LogName = "Application";
if (!EventLog.SourceExists(LogName)) {
369

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

EventLog.CreateEventSource(LogName, LogName);
}
// Insert into event log
EventLog Log = new EventLog();
Log.Source = LogName;
Log.WriteEntry(Message, EventLogEntryType.Error);
}
.
.
. IIS
[Global.asax]
<%@ Import Namespace="System.Diagnostics" %>
<script language="C#" runat="server">
void Application_Error(Object sender, EventArgs e) {
String Message = "\n\nURL:\n http://localhost/" + Request.Path
+ "\n\nMESSAGE:\n " + Server.GetLastError().Message
+ "\n\nSTACK TRACE:\n" + Server.GetLastError().StackTrace;
// Create Event Log if it does not exist
370

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

;"String LogName = "Application


{ ))if (!EventLog.SourceExists(LogName
;)EventLog.CreateEventSource(LogName, LogName
}
// Insert into Event Log
;)(EventLog Log = new EventLog
;Log.Source = LogName
;)Log.WriteEntry(Message, EventLogEntryType.Error
}
></script

-1 :
.
-2
) ( .
ASP.NET .
-3 client client
ASP.NET . client ) client

371

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

( .
.
-4
. > <customErrors ><error HTTP
.
-5 . Page
Page_Error override .
.
-6 System.Web.Mail
.
-7 Application_Error Global.asax
. .
-8 System.Diagnostics .

372

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com


QueryString .

.
.
VS.net C# Application ASP.net Web
Application . WebForm1.aspx Toolbox
Label WebForm1 Label1 .

Base64String
Base64String String ) string(
) !( " "I LOVE ASP.net
Base64String " ." =SSBMT1ZFIEFTUC5uZXQ
;"string String = "I LOVE ASP.net
;)byte [] Byte = System.Text.Encoding.ASCII.GetBytes(String
;)Label1.Text = Convert.ToBase64String(Byte
1
373

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

string byte Byte


Byte Base64String Label1 .
Base64String !

;"=string MyBase64String = "SSBMT1ZFIEFTUC5uZXQ
;)byte[] MyByte =Convert.FromBase64String(MyBase64String
;)Label1.Text = System.Text.Encoding.ASCII.GetString(MyByte
! !" "I LOVE ASP.net
! Base64String byte byte string .
.
Base64String :
" "=VHJ5IHRvIGZpbmQgd2hhdCB5b3UgbmV2ZXIgbG9vc2U !
" "jcUKVu8D4dlpy4BHw6bgefaVMWW9x0qV
string
!
Cryptography TripleDESMD5
Base64String

MSDN . :
374

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

. DES :TripleDES
Data Encryption Standard. :DES
. :MD5
.( Hash function) Hash ComputeHash MD5
binary string binary string ( Hash functions) Hash
!
.( Hash )
.(! )
byte[] IV = new byte[8] {240, 32, 45, 29, 0, 76, 173, 59};
string cryptoKey = "All you need is Love";
string MyString = "I LOVE ASP.net";
byte[] buffer = System.Text.Encoding.ASCII.GetBytes(MyString);
TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider();
MD5CryptoServiceProvider MD5 = new MD5CryptoServiceProvider();
des.Key =
MD5.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(cryptoKey));
des.IV = IV;
byte[] CodedBuffer =
des.CreateEncryptor().TransformFinalBlock(buffer,0,buffer.Length);
Label1.Text = System.Convert.ToBase64String(CodedBuffer,0,CodedBuffer.Length);
cryptoKey IV
375

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

)DESCryptoServiceProvider (TripleDESCryptoServiceProvider
Key IV Initialization Vector )

Key IV DESCryptoServiceProvider
( . IV
IV !
IV byte cryptoKey string "All you need
"is Love " "All you need is Love . MyString
string ) . C#
(.
:des.Key Key
MD5.ComputeHash Key
MD5.ComputeHash string cryptoKey
byte (System.Text.ASCIIEncoding.ASCII.GetBytes(cryptoKey)).
CreateEncryptor TransformFinalBlock
Hash byte .
byte string Base64String
.

376

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

TripleDESCryptoServiceProvider

System.Security.Cryptography MD5CryptoServiceProvider

using System.Security.Cryptography namespace
.

: CreateDecryptor
byte[] IV = new byte[8] {240, 32, 45, 29, 0, 76, 173, 59};
string cryptoKey = "All you need is Love";
string CodedString64 = "zNvKahC6S/+8xMX3o658wQ==";
byte[] buffer = Convert.FromBase64String(CodedString64);
TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider();
MD5CryptoServiceProvider MD5 = new MD5CryptoServiceProvider();
des.Key =
MD5.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(cryptoKey));
des.IV = IV;
byte[] CodedBuffer =
des.CreateDecryptor().TransformFinalBlock(buffer,0,buffer.Length);
Label1.Text = System.Text.Encoding.ASCII.GetString (CodedBuffer);
" ) jcUKVu8D4dlpy4BHw6bgefaVMWW9x0qV "
! IV Key IV ( !
! " ! red rose" Key
377

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com



TripleDES
DES ) !(.
Key )
email ! 10000
!( . server
Key Web.config ! .

378

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

) (Whois ASP.NET

www.Register.com

.
ASP.NET .

Query . TCP 43
. 2 .

:
;Using System. NET.Sockets
;Using System.Text
Using System.IO
;Using System.Text.RegularExpressions
TcpClient NetFramework. .
System. NET.Sockets .
.
1
www.mit.edu/afs/athena/contrib/potluck/net-services/whois-servers.list 2
379

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Query
:
;string StrSvr,StrDomain, Resp
;TcpClient TcpClt
;byte[] ArrDomain
;Stream TcpStr
;StreamReader TcpStrRdr
Query .
)(... OrgCom .
. whois.internic.com
.NET com. edu. Info.
.
.
DropDownList :
|| "if (DDLstSuffix.SelectedItem.Value == ".COM
== DDLstSuffix.SelectedItem.Value == ".NET" || DDLstSuffix.SelectedItem.Value
)"".EDU
{
;"StrSvr = "whois.internic.net
StrDomain = TxtDomainName.Text.Trim() + DDLstSuffix.SelectedItem.Value+
;""\r\n
380

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

}
else if (DDLstSuffix.SelectedItem.Value == ".ORG")
{
StrSvr = "whois.publicinterestregistry.net";
StrDomain = TxtDomainName.Text.Trim() + DDLstSuffix.SelectedItem.Value+
"\r\n";
}
else if (DDLstSuffix.SelectedItem.Value == ".BIZ")
{
StrSvr = "whois.neulevel.biz";
StrDomain = TxtDomainName.Text.Trim() + DDLstSuffix.SelectedItem.Value+
"\r\n";
}
else if (DDLstSuffix.SelectedItem.Value == ".INFO")
{
StrSvr = "whois.afilias.info";
StrDomain = TxtDomainName.Text.Trim() + DDLstSuffix.SelectedItem.Value+
"\r\n";
}
else if ((DDLstSuffix.SelectedItem.Value == ".IR") || (DDLstSuffix.SelectedItem.Value
== ".CO.IR") || (DDLstSuffix.SelectedItem.Value == "..NETIR") ||
(DDLstSuffix.SelectedItem.Value == "ID.IR"))
{
StrSvr = "whois.nic.ir";
StrDomain = TxtDomainName.Text.Trim() + DDLstSuffix.SelectedItem.Value+
"\r\n";
}
381

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

"\ "r\n .
.


. TcpClient
. :
-1 TcpClient : Connect
;)(TcpClient TcpClt = new TcpClient
;)TcpClt.Connect(StrSvr,43
-2 TcpClient
. Constructor :
;)TcpClient objTCPC = new TcpClient(StrSvr, 43
GetBytes ) Encoding (System.Text StrDomain
.
;)ArrDomain = Encoding.ASCII.GetBytes(strDomain
GetStream TcpClient Stream
:
382

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

;)(TcpStr = TcpClt.GetStream
Stream Write Byte Stream :
;)TcpStr.Write (ArrDomain,0,StrDomain.Length


StreamReader
Encoding .
;)TcpStrRdr = new StreamReader(TcpClt.GetStream(),Encoding.ASCII
ReadToEnd .
" "\n "> "<br . Replace RegEx
:
;)">Resp = Regex.Replace(TcpStrRdr.ReadToEnd(),"\n","<br
;)(Resp = Resp.ToLower
" "no match " "not found " "no entries found
. .
. IsMatch RegEx
. True False
.
383

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

if (Regex.IsMatch(Resp,"no match") || Regex.IsMatch(Resp,"not found") ||


Regex.IsMatch(Resp,"no entries found"))
{
SearchRes = " ;"
PnlOrder.Visible = true;
PnlOrderOk.Visible = false;
}
else
{
SearchRes = " ;"
PnlOrder.Visible = false;
PnlOrderOk.Visible = false;
}
.
TcpClt.Close();
Build a WHOIS Lookup in ASP.NET:

www.sitepoint.com/article/build -whois-lookup -asp-net

384

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

PDF... DOC JPG .



URL Spider

.
URL

.


URL
URL . Authentication
ASP.net .
32sdf43ef45.pdf
. Spider Hacker
.

1
385

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

HttpHandler.
HttpHandler
HttpHandler API Request/Response
. Handler
doc. .

E-Commerce FTP .

Web.Config
: web.config Secure .
><HttpHandlers
><add verb="*" path="*.doc" type="pdfIntercept.pdfHandler, pdfInterceptX" /
></HttpHandlers
IHttpHandler doc
.
verb POST GET HEAD *
.
386

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Path * doc.
doc
Type Handle .
.
][NAMESPACE].[CLASS], [ASSEMBLY NAME

Custom Extension
IIS .
:
Read : False
Write: False
Directory Browsing: False
IIS Manager Properties/Edit Home
Configuration . doc, pdf
. add .
HttpHandler .

387

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

HttpHandler
Authentication . HttpHandler
.
using System;
using System.Web;
using System.IO;
namespace pdfIntercept
{
public class pdfHandler : IHttpHandler
{
//Notice ProcessRequest is the only method
//exposed by the IHttpHandler
public void ProcessRequest(HttpContext context)
{
try
{
string strString = "yes";
HttpRequest oRequest = context.Request;
HttpResponse oResponse = context.Response;
//ADD YOUR CUSTOM AUTHENICATION HERE
//ADD YOUR CUSTOM AUTHENICATION HERE
388

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

//ADD YOUR CUSTOM AUTHENICATION HERE


//ADD YOUR CUSTOM AUTHENICATION HERE
if (strString == "yes")
{
//Since they've made it this far, they've been validated
//by your system
//We'll fire up a FileStream object
FileStream MyFileStream;
long FileSize;
//Map the path to the .doc file
//You might need to parse out the Request path to figure out
//what resource they're actually requesting
string strMapPath = context.Server.MapPath("book1.doc");
MyFileStream = new FileStream(strMapPath, FileMode.Open);
FileSize = MyFileStream.Length;
//Allocate size for our buffer array
byte[] Buffer = new byte[(int)FileSize];
MyFileStream.Read(Buffer, 0, (int)FileSize);
MyFileStream.Close();
//Do buffer cleanup
context.Response.Buffer = true;
context.Response.Clear();
389

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

//Add the appropriate headers


context.Response.AddHeader("content-disposition",
"attachement filename=x.doc");
//Add the right contenttype
context.Response.ContentType = "application/doc";
//Stream it out via a Binary Write
context.Response.BinaryWrite(Buffer);
}
else
{
//It's a bogus request and they weren't validated.
context.Response.Write("<b>DENIED</b>");
}
}
catch (System.Exception err)
{
err.ToString();
}
}
//By calling IsReusable, an HTTP factory can query a handler to
//determine whether the same instance can be used to service
//multiple requests
390

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

public bool IsReusable


{
get
{
return false;
}
}
}
}
Response.WriteFile binary stream
.
if (strString == "yes")
{
context.Response.Buffer = true;
context.Response.Clear();
context.Response.AddHeader("content-disposition",
"attachement; filename=x.doc");
context.Response.ContentType = "application/doc";
context.Response.WriteFile("pp.doc");
}
else
{
context.Response.Write("<b>DENIED</b>");
}
391

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

:
HttpHandler -1 doc .
-2
.
-3 Binary Stream .
-4 Denied
HttpHandler .
E-Commerce
. URL
.

392

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET

.
.
www.iranasp.net/download/hrooznamechi002.zip :

.
. .
ASP.NET
.
Graphics .
DrawImage .
DrawImageUnscaled
.
:
- 1 ) (.

1
393

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

- 2 )
(.
- 3 )
(.
:
- 1 ImageAttributes
.
- 2 Graphics
.
DrawImage ". "myGraphics
graphics " "img .
)
result.jpg
readme.doc (.
- 1 :
)>myGraphics.DrawImage(img,<point

394

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

X Y .
. )
(
)
( .
- 2 :
)myGraphics.DrawImage(img,BiggerRectangle
) BiggerRectangle
( . .
- 3 :
DistRectangle=new Rectangle(100,100,10,10)//
)myGraphics.DrawImage(img, DistRectangle,75,40,10,10,GraphicsUnit.Pixel
) ( DrawImage
. GraphicsUnit Pixel .
.
.
- 4 :

395

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

DistRectangle =new Rectangle(10,20,120,40) )//


SourRectangle =new Rectangle(75,40,10,10) )//
myGraphics.DrawImage(img, DistRectangle, SourRectangle,GraphicsUnit.Pixel)
Graphics ( transformation) ( Rotating)
30 . transformation .
.
: - 5
Matrix mx = new Matrix();
mx.Rotate(-30);
myGraphics.Transform = mx;
myGraphics.DrawImage(img,new Point(100,50));
.
: - 6
Matrix mx = new Matrix();
mx.Translate(20.0F, 10.0F);
myGraphics.MultiplyTransform(mx);
myGraphics.RotateTransform(20.0F);
. Y X 10,0 F 20,2 F

396

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET


.()
.
: - 7
Rectangle DistRectangle = new Rectangle(50,50,320,240);
Rectangle SourRectangle= new Rectangle(0, img.Height, img.Width,- img.Height);
myGraphics.DrawImage(img,DistRectangle,SourRectangle,GraphicsUnit.Pixel);
. ImageAttributes
. alpha ColorMatrix
ColorMatrix.Matrix33 property
.
: - 8
myGraphics.DrawImage(img1,new Point(0,0));
ImageAttributes ia = new ImageAttributes();
ColorMatrix cm = new ColorMatrix();
cm.Matrix33=0.5f;
ia.SetColorMatrix(cm);
myGraphics.DrawImage(img2,new Rectangle(0, 0, img2.Width, img2.Height ), 0, 0,
img2.Width, img2.Height, GraphicsUnit.Pixel, ia);
: Thumbnail - 9
397

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Thumbnail .
Graphics
) (10 . Thumbnail
.
:
System.Drawing.Image.GetThumbnailImageAbort myCallBack = new
;)System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback
= System.Drawing.Image imgResizedImage
;)MainPic.GetThumbnailImage(360,270,myCallBack,IntPtr.Zero
:
) : callback (callbackData callback
Image.GetThumbnailImageAbort . GDI+1 0
. ) (.
callbackData IntPtr.Zero.
Thumbnail
Thumbnail .
) 120 (120
.

398

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

DrawImage .
.
- 10 :
;)System.Drawing.Image NewImage = new System.Drawing.Bitmap(300,300
= System.Drawing.Graphics NewImageGraphics
;)System.Drawing.Graphics.FromImage(NewImage
;)Rectangle DistRectangle = new Rectangle(0,0,NewImage.Width,NewImage.Height
;)Rectangle SourRectangle = new Rectangle(0,0,my1stImage.Width,my1stImage.Height
NewImageGraphics.DrawImage(my1stImage,DistRectangle,SourRectangle,GraphicsUn
;)it.Pixel
Image NewImage Bitmap

.
. )(
result.jpg .
IIS NET Framework. .

399

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET

ASP.NET
.
) (CLIENT .
4 .
.
: ) (session ) . (persistent
.
.
.
.
. .
.

.
. .

1
400

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

HttpCookie System.Web .
Response Request
HttpCookieCollection .
HttpCookieCollection
. HttpCookie
. Name Value
. Expires HttpCookie
. UID PASS.
Response.Cookies.Add :
Listing 1. Creating cookies
'
'
)"Dim cookie As HttpCookie = New HttpCookie("UID
"cookie.Value = "myid
cookie.Expires = #9/28/2002#
)Response.Cookies.Add(cookie
)"cookie = New HttpCookie("PASS
"cookie.Value = "mypass
cookie.Expires = #9/28/2002#
)Response.Cookies.Add(cookie

401

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

. Request.Cookies
: ListBox
Listing2 . Read cookies
'
Dim cookieCols As New HttpCookieCollection()
cookieCols = Request.Cookies
Dim str As String
'
For Each str In cookieCols
ListBox1.Items.Add("Cookie: " + str)
ListBox1.Items.Add("Value:" & _
Request.Cookies(str).Value)
Next
HttpCookieCollection Remove Clear
: Remove .
Listing3 . Deleting cookies
Dim cookieCols As New HttpCookieCollection()
cookieCols = Request.Cookies
Dim str As String
'

402

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

Request.Cookies.Remove("PASS")
Request.Cookies.Remove("UID")
. .
. Values
.
Listing4 . Creating a dictionary cookie
Dim cookDict As HttpCookie = New HttpCookie("dict")
cookDict.Values("fname") = "first name"
cookDict.Values("lname") = "last name"
cookDict.Values("Address") = "address"
Response.Cookies.Add(cookDict)
Asp.Heaven :

403

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

404

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

HTML

HTML ASP.NET
www.iranasp.net/download/htmlcontrols.zip :
ASP.NET : HTML Web.
HTML HTML .
HTML HTML
ASP.NET .
HTML .
.
><html
><head><title>SimpleHTML.htm</title></head
><body
>"<form method="post" action="SimpleHTML.htm
Enter your favorite color:
><br
>"<input name="favColor" type="text
><p
>"!<input type="submit" value="Submit
1
405

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

></form
></body
></html


.
ASP.NET .
><html
><head><title>SimpleASPX.aspx</title></head
><body
>"<form runat="server
Enter your favorite color:
><br
>"<input id="favColor" type="text" runat="server
><p
>"<input type="submit" value="Submit!" runat="server
></form

406

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

></body
></html
HTML
:
aspx .
" runat="server .
name id > <input .
Method Action > <form ASP.NET
.

. HTML HTML ASP.NET
.

407

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET

ASP.NET
www.iranasp.net/download/webcontrols.zip :
HTML .
HTML
. HTML > <select
ListBox ComboBox InputLine
TextBox > <input > <textarea.
ASP.NET . ASP.NET
.
HTML HTML
. ASP.NET :

:TextBox )( .

: Label .

: CheckBox /.

: RadioButton .

: HyperLink ( ( .

1
408

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

: Button HTML
.

: LinkButton HTML
.

: ImageButton HTML
.
HTML . ASP.NET

TextBox Button .
><html
><head><title>Guestbook.aspx</title></head
><body
><h3>Please Sign Our Guestbook!</h3
>"<form runat="Server
Your Name:
><br
<asp:TextBox
"ID="username
>runat="Server" /
><p

409

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Comments:
><br
<asp:TextBox
"ID="comments
"TextMode="Multiline
"Columns="50
"Rows="4
>runat="Server" /
><p
<asp:Button
"!Text="Submit
>Runat="Server" /
></form
></body
></html
.
. TextBox
.
<asp:TextBox
"ID="username
>runat="Server" /
410

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

:
)(... Label TextBox
ID
" runat="Server
HTML .

411

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET

ASP.NET
www.iranasp.net/download/eventhandle.zip :
HTML ) (Button )( ) (Event
) (ComboBox .

.
Load Init Unload .
/ ) (checkbox .
HTML ASP.NET .
. ) (Event Handling
.
.
HTML
HTML ASP.NET ServerClick .
.

1
412

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

. ServerClick
.
<Script runat="Server">
Sub submitText( s As Object, e As EventArgs )
mySpan.InnerHtml = StrReverse( myTextArea.Value )
End Sub
</Script>
<html>
<head><title>HtmlControlEvents.aspx</title></head>
<body>
<form runat="server">
Enter some text:
<br>
<textarea
id="myTextArea" cols="30" rows="3"
runat="Server"></textarea>
<p>
<input type="submit" value="Submit Text!"
runat="server" onServerClick="submitText">
413

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

><p
><span id="mySpan" runat="server"></span
></form
></body
></html
HTML :
"!<input type="submit" value="Submit Text
>"runat="server" onServerClick="submitText
" onServerClick="submitText .
onServerClick submitText .
submitText .
textbox > <span .
submitText : object EventArgs.
object .
. EventArgs .
.

414

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

. HTML
. Click Button
.
<Script runat="Server">
Sub submitText( s As Object, e As EventArgs )
myLabel.Text = StrReverse( myTextBox.Text )
End Sub
</Script>
<html>
<head><title>WebControlEvents.aspx</title></head>
<body>
<form runat="server">
Enter some text:
<br>
<asp:TextBox
id="myTextBox"
TextMode="Multiline"
Columns="30"
Rows="3"
Runat="Server" />
415

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

<p>
<asp:Button
Text="Submit Text!"
runat="server"
onClick="submitText" />
<p>
<asp:Label
id="myLabel"
runat="server" />
</form>
</body>
</html>
: Button
<asp:Button
Text="Submit Text!"
runat="server"
onClick="submitText" />
Button Click onClick
. Button . submitText
Textarea submitText
. Label

416

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Label

Label
www. iranasp.net/download/labelcontrol.zip :
ASP.NET Label
. Text
.
Page-Load .
>"<Script runat="Server
Sub Page_Load
) "lblDate.Text = Now.ToString( "D
End Sub
></Script
><html
><head><title>ShowDate.aspx</title></head
><body
<asp:Label
"id="lblDate

1
417

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

Runat="Server" />
</body>
</html>

.
. 24 p Verdana
<Script runat="Server">
Sub Page_Load
lblDate.Text = Now.ToString( "D" )
End Sub
</Script>
<html>
<head><title>LabelFormat.aspx</title></head>
<body>
<asp:Label
id="lblDate"
ForeColor="Blue"
BackColor="Yellow"
Font-Name="Verdana"
Font-Size="24pt"
418

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

Runat="Server" />
</body>
</html>

419

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ListBox ArrayList

ArrayList .
www.iranasp.net/download/shahoo03.zip :
ASP.NET ListBox Page_Load .
ASP.NET ) ( Data souce .
.
ASP.NET ArrayList .

) (Objects Collection . ArrayList .
ListBox Datasource .
Datasource . DataBind
ListBox . ArrayList
ListBox ) (lstFlowers ArrayList .
.
><% @Page Language="VB" Debug="True" %
><html><head><title>Databing Demo</title></head
><body
>"<form runat="server
Select a flower, and then click the submit button please:
1
420

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

<br>
<asp:ListBox id="lstFlowers" runat="server" rows="3"
AutoPostBack="True" onSelectedChanged="showSelection"/>
</asp:ListBox>
<br><br>
<asp:Label id=lblMessage runat="server"></asp:Label></p>
</form>
</body></html>
<script language=vb runat="server">
sub Page_Load(source As Object, e As EventArgs)
if Not Page.IsPostBack Then
Dim myArrayList As New ArrayList
myArrayList.Add("Azalea")
myArrayList.Add("Tulip")
myArrayList.Add("Rose")
lstFlowers.DataSource=myArrayList
lstFlowers.DataBind()
lstFlowers.SelectedIndex=0
end if
end sub
sub showSelecttin(Sender As Object, e As EventArgs)
lblMessage.Text="You have selected " +lstFlowers.SelectedItem.Text
end sub
</script>

421

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

HyperLink

HyperLink
www.iranasp.net/download/shahoo02.zip :
)( ASP.NET HyperLink .
Text NavigateUrl
ImageUrl
NavigateUrl .

( hyper.gif ).
><%@ Page Language="VB" Debug="True" %
><html
><head
><title>HyperLink Control</title
></head><body
"<asp:HyperLink id="hl1" runat="server
"NavigateUrl="http://www.iranasp.net
>Text=" Go to IranASP.NET" /
><br
"<asp:HyperLink id="hl2" runat="server
"NavigateUrl="http://www.iranasp.net/forum
"ImageUrl="hyper.gif
1
422

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

Text="Go to IranASP.NET Forum"/>


<br>
<br>
</body>
</html>

423

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET
.
.
ASP .
VB VBScript . ASP
. Visual InterDev
. InterDev
.
Web Form ASP.NET
HTML .
Web From
. Hello World
.

1
424

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

.
2000 .
2000 ) (Professional
Professional .4
.NET Framework
. .
NTFS
.
Hello World
ASP.NET Web Application
HelloWorld . http://localhost.
OK solution .
Web Form WebForm1.aspx . .
OK .
Visual Studio Projects web application
. :
inetpub/wwwroot .
IIS Application script .
425

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

FrontPage Server Extensions FrontPage Web


FrontPage .
Web Form
toolbox web
form . Label toolbox text
Hello World .
. .
toolbar Solution Configuration release debug .
F5 . WebForm1.aspx
Hello World .
View Source
. HTML aspx
.
HTML Form
Label . span .
span container Label .
.

426

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Web Form . Web From


. Hello World Web
Form .WebForm1.aspx : Web Form .
Project | Add Web Form . Web Form
WebForm2.aspx ) .
(
Open WebForm2.aspx solution . WebForm2.aspx
Solution Explorer .
Label Button .
Label Properties ID lblText .
ID btnSubmit .
Enter .
ASP.NET .
btnSubmit_Click .
.
:
"lblText.Text = "Hello World

427

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

IntelliSense lblText
Label . InterDev
.
Web Form Text Submit
. . F5
WebForm1.aspx .
WebForm2.aspx Solution Explorer WebForm2.aspx
Set As Start Page . .
Web FormWebForm2.aspx
Label . Label
. .

428

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET

ASP.NET ASP
.
ASP HTML
. ASP ASP.NET
ASP HTML . ASP
HTML
.
) (Execute HTML .
aspx . ) IIS
Server .NET Framework (
aspx runtime ASP.NET .
ASP
. ASP
. aspx .
) ( aspx aspx.vb
HTML ASP
.
1
429

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Global.asax Global.asa ASP .


Web.Config XML
.
.
cache .
.

. DLL .
aspx . DLL
. aspx DLL .
HelloWorld WebForm2 .
:
WebForm2.aspx
WebForm2.aspx.vb
Global.asax
Global.asax.vb
Web.Config
Global.asax
. F5 WebForm2.aspx Global.asax
. WebForm2.aspx.vb
430

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Global.asax.vb HelloWorld.dll
.
aspx ASP.NET cls
dll . dll HelloWorld.dll
HTML .
.NET Framework System .
aspx System.Web.UI.Page .
aspx ) ( system.web.ui.page .
Request Response ... .

.
. .

431

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

html
.

ASP .
:
.
.
aspx ( vb cs (
.

.

.

aspx vb
Solution Explorer Show All Files .
1
432

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

aspx vb . WebForm2.aspx.vb
WebForm2 .
System.Web.UI.Page Response , Request ,
Server , Session Application .
WithEvents .

.
ASP 50 100 .
.
.
.
ActiveX
ActiveX . ActiveX HTML
.
HelloWorld . WebForm3.aspx
. toolbox Calendar
. !! ASP & Drag
Drop !!

433

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

!
:

-------------------------------ID

myCal

BackColor

A light yellow ( #ffffc0)

BorderColor

Black

BorderStyle

Solid

BorderWidth

1px

DayHeaderStyle , BackColor

Light orange ( #ffc080)

DayHeaderStyle , BorderColor

Dark red ( #c00000)

DayHeaderStyle , BorderStyle

Inset

DayHeaderStyle , BorderWidth

1px

DayHeaderStyle , Font , Bold


DayNameFormat
Font , Name
Font , Size

True

Short

Verdana
X-Small

NextPrevFormat

ShortMonth

OtherMonthDayStyle , ForeColor

Silver

SelectedDayStyle , BackColor

Dark blue ( #0000c0)

SelectedDayStyle , ForeColor

White

. WebForm3.aspx
Internet . toolbox
. Netscape 4 Explorer
434

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com


ASP.NET Server Control HTML Server Control Validation Control
.

. :
HTML Server Control
ASP.NET Server Control
Validation Control
User Control
Server-Side Control .
Server-Side Control
ASP ASP > % <% HTML .
HTML ASP .
.
. nm .
. Request

1
435

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

value .
.

.
submit .
" runat="server . " runat="server
:
><HTML
><HEAD
><title>Untitled</title
></HEAD
><BODY
>"<Form Action="testform.aspx" runat="server
? What is your name
"<asp:textbox name="nm
"value="" size="40
>MAXLength="40" runat="Server"/><br
>" <input Type="submit" Name="cmd" Value=" Submit
></FORM
></BODY
></HTML

436

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

aspx ASP.NET .
. ASP
aspx . = server .
ASP.NET .
.
HTML form
ID Name __ VIEWSTATE
.
HTML Server Control
HTML Server Control " runat="server .
) (Toolbox .
HTML HTML . HTML Server
" runat="server .
HTML Server Control HTML
CheckBox , ListBox , TextBox , Table , Form .
.
HTML
. HTML

437

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

"runat="server Design
Run As Server Control .
HTML System.Web.UI.HTMLControls .
HTML HTML Server Control
:

.
client
.
.
HTML Server Control ASP
. ASP ASP.NET .
HTML Server Control ASP.NET Server Control
.
ASP.NET Server Controls
HTML Server Control HTML
. ASP.NET Server Controls
.

438

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

VB.NET ASP.NET Server TextBox


DataGrid . <asp:
. WebForm1.aspx Label Text
HelloWorld :
><asp:label id="Message" text="Hello World" runat="server"/
View HTML Source
. " input type="Submit
:
><asp:button text="Go!" runat="server"/
HTML ASP.NET Server.
HTML .
Validation Controls
.
Client .

.

ControlToValidate . :
439

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com




:
:RequiredFieldValidator .
:CompareValidator .
:RangeValidator .
:RegularExpressionValidator
.
CustomValidator .
.
HelloWord . ID
txtName . RequiredFieldValidator
. Text Submit .
ID rfvTxtName .
.
ControlToValidate txtName . ErrorMessage Required
Field. Please enter your name . .
440

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

WebForm4.aspx .
.
.
.
HTML
.
.
User Controls
.
.

441

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com


.
.
. HTTP
. :
.
.
HTML .
.
.
.
.
.

. .
.

1
442

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com



. 6
Form_Unload Form_QueryUnload Form_Load Form_Initialize
Form_Terminate.

. HTML
. .
:
: Form_Initialize Form_Load 6 .
Page_Load .
. .
:
.
.
: .
Form_Unload Form_Terminate .

443

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

.
Page_Unload .

:


Postbacknon-Postback

ApplicationSession

.
Client
ASP.NET Server
HTML .
MouseMove .
Postbacknon-Postback

444

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET .
OnChange
.
. .

DataGrid
DataGrid container . ) (
. container container
ItemCommand .
.
Application Session
ASP Application Session
SessionStart ApplicationEnd ApplicationStart SessionEnd.
.

445

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

DataGrid

DataGrid
www.iranasp.net/download/pourshahid01.zip :

.
AutoGenerateColumns=True DataGrid
BoundColumn
.
. Data
Grid .
System.Data
) ASP.NET C# VB.NET JS.NET
(.
CreateDataSource
.
) ( Page_Load

1
446

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

DataGrid
. HTML
<%@ Import Namespace ="System.Data" %>
<html>
<script language="VB" runat="server">
Function CreateDataSource() As ICollection
Dim dt As DataTable
Dim dr As DataRow
Dim i As Integer
'create a DataTable
dt = New DataTable
dt.Columns.Add(New DataColumn("IntegerValue", GetType(Integer)))
dt.Columns.Add(New DataColumn("StringValue", GetType(String)))
dt.Columns.Add(New DataColumn("DateTimeValue", GetType(Boolean)))
dt.Columns.Add(New DataColumn("BoolValue", GetType(Integer)))
dt.Columns.Add(New DataColumn("CurrencyValue", GetType Double)))
'Make some rows and put some sample data in
For i = 1 To 9
dr = dt.NewRow()
dr(0) = i
447

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

dr(1) = "Item " + i.ToString()


dr(2) = DateTime.Now.ToShortTimeString
If (i Mod 2 <> 0) Then
dr(3) = True
Else
dr(3) = False
End If
dr(4) = 1.23 * (i+1)
'add the row to the datatable
dt.Rows.Add(dr)
Next
'return a DataView to the DataTable
CreateDataSource = New DataView(dt)
End Function
Sub Page_Load(sender As Object, e As EventArgs)
MyDataGrid.DataSource = CreateDataSource
MyDataGrid.DataBind
End Sub
</script>
<body>
<h3><font face="Verdana">Simple DataGrid Example</font></h3>
<form runat=server>
448

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

<ASP:DataGrid id="MyDataGrid" runat="server"


BorderColor="black"
BorderWidth="1"
GridLines="Both"
CellPadding="3"
CellSpacing="0"
Font-Name="Verdana"
Font-Size="8pt"
HeaderStyle-BackColor="#aaaadd"
/>
</form>
</body>
</html>

449

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

AdRotator

AdRotator
.
Rotator Schedule .
( Properties) Advertisement File . XML
. AdRotator
File :AdRotator.aspx
<%@ Page Language="VB" %>
<html>
<body>
<H1>AdRotator in ASP.NET</H1>
<asp:AdRotator id=MyAdRotator runat=server
AdvertisementFile="Advertisement.xml"
BorderWidth=2 />
</body>
</html>

1
450

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

. Advertisements XML ( Root Element)


. Ad ( Child Element)
.< Ad>
File : Advertisement.xml
<Advertisements>
<Ad>
<ImageUrl>images/banner1.gif</ImageUrl>
<NavigateUrl>http://www.Iranasp.net</NavigateUrl>
<AlternateText>ASP.NET</AlternateText>
<Keyword>ASP</Keyword>
<Impressions>5</Impressions>
</Ad>
<Ad>
<ImageUrl>images/banner2.gif</ImageUrl>
<NavigateUrl>http://www.Pishgaman.com</NavigateUrl>
<AlternateText>YAZDISP</AlternateText>
<Keyword>ISP</Keyword>
<Impressions>5</Impressions>
</Ad>
</Advertisements>
. URL:Image URL
. URL : URL Navigate
. : Alternate Text
451

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

: Keyword .
: Impressions .
AdRotator ) XML (
HTML Client ) Imperssions
(.
Keyword
Filter .
http://www.iranasp.net .
File :AdRotator.aspx
<asp:AdRotator id=MyAdRotator runat=server
"AdvertisementFile="Advertisement.xml
"KeywordFilter="ASP
>BorderWidth=2 /
:
http://www.123aspx.com
http ://www.aspnextgen.com

452

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET


ASP.NET .

.
. ASP.NET
.
.
ASP.NET
HTML .
.
ASP.NET
.
True False
.

.
False .
1
453

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com


.

.
10 5
.

ASP.NET :
RequiredFieldValidator
ReqularExpressionValidator
CompareValidator
RangeValidator
CustomVlidator
ValidationSummary
. BaseValidator
WebControl System.UI.WebControls Control
System.Web.UI . Text Label
.
.
454

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

: ControlToValidate ID TextBox
. .
: Display . :
: None

ValidationSummary .

.
: Static
.

.
:Dynamic Static
.
.
: Enabled .
: EnabledClientScrip .
: ErrorMessage .
455

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

: ForeColor .
: IsValid .
: Visible .
) ASP.NET (

www.nashreoloom.com/showbooks.aspx@id=110

456

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ViewState -

ASP .
ASP.NET ViewState .
Back ...
. ViewState !
ASP.NET )(
.! ASP.NET ViewState
. ViewState
)( . :
) (Hidden Field . >"<Form runat="server
ASP.NET . :
>"<Form name="_ct10" method="post" action="page.aspx" id="_ct10
"<input type="hidden" name="__VIEWSTATE
>value="dDwtNTI0ODU5MDE1Ozs+ZBCF2ryjMpeVgUrY2eTj79HNl4Q" /
some code
></form
ViewState ASP.NET WebForm .
ViewState Directive aspx :

1
457

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

<% @Page EnableViewState="false" %>


. EnableViewState
[ASPX page]
<asp:label id="myLabel" runat="server" EnableViewState="false"></asp:label>
[codebehind]
myLabel.EnableViewState = false
: ViewState
<script runat="server">
Sub submit(sender As Object, e As EventArgs)
lbl1.Text="Hello " & txt1.Text & "!"
End Sub
</script>
<html>
<body>
<form runat="server">
Your name: <asp:TextBox id="txt1" runat="server" />
<asp:Button OnClick="submit" Text="Submit" runat="server" />
<p><asp:Label id="lbl1" runat="server" /></p>
</form>
</body>
</html>

458

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ViewState -

ASP .
ASP.NET ViewState .
serializable TypeConverter
ViewState . serializable
TypeConverter ViewState
.
String ArrayList HashTable .
ViewState
round-trip
.
ViewState
) (Connection String ViewState .

EnableViewState
ViewState .
DataList Repeater DataGrid ViewState
. false
1
459

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

EnableViewState
.
Session ViewState .
:
][C#
;"ViewState["MyData"] = "This is some data.
][VB.NET
"ViewState("MyData") = "This is some data.
ViewState
ViewState .
:
][C#
;]"string strTmp = (string) ViewState["MyData
][VB.NET
)]"Dim strTmp As String = CStr(ViewState["MyData
Label
ViewState .
][VB.NET
' This control renders values stored in view state for Text and FontSize properties.
460

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

Imports System
Imports System.Web
Imports System.Web.UI
Namespace ViewStateControlSamples
Public Class LabelVB : Inherits Control
' Add property values to view state with set;
' retrieve them from view state with get.
Public Property [Text] As String
Get
Return CStr(ViewState("Text"))
End Get
Set
ViewState("Text") = Value
End Set
End Property

Public Property FontSize As Integer


Get
Return CInt(ViewState("FontSize"))
End Get
Set
ViewState("FontSize") = Value
461

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

End Set
End Property
Protected Overrides Sub Render(Output As HtmlTextWriter)
Output.Write("<font size=" & Me.FontSize & ">" & Me.Text & "</font>")
End Sub
End Class
End Namespace
[C#]
// This control renders values stored in view state for Text and FontSize properties.
using System;
using System.Web;
using System.Web.UI;
namespace ViewStateControlSamples {
public class Label: Control {
// Add property values to view state with set;
// retrieve them from view state with get.
public String Text {
get {
return (String) ViewState["Text"];
}
462

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

set {
ViewState["Text"] = value;
}
}

public int FontSize {


get {
return (int) ViewState["FontSize"];
}
set {
ViewState["FontSize"] = value;
}
}
protected override void Render(HtmlTextWriter output) {
output.Write("<font size=" + this.FontSize + ">" + this.Text + "</font>");
}
}
}

463

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ListBox


ListBox .
ASP.NET
ListBox .
ASP.NET RequiredFieldValidator .
ControlToValidate ListBox !
:
ASP.NET



. RequiredFieldValidator

.
:

1
464

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

BaseValidator ) ( .
Client Side .
Server Side
.
RequieredItem
)
SelectionMode ListBox Multiple (.
DropDownList
CheckBoxList RadioButtonList .
:
][C#
;using System
;using System.Text
;using System.Web.UI
;using System.Web.UI.WebControls
namespace MyLib
{
>/// <summary
/// Summary description for RequieredListBoxValidator.
>/// </summary
public class RequieredListBoxValidator : BaseValidator
{
465

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

protected int _RequieredItem = 1;


public int RequieredItem
{
get
{
return this._RequieredItem;
}
set
{
this._RequieredItem = value;
}
}
protected override bool ControlPropertiesValid()
{
return true;
}
protected override bool EvaluateIsValid()
{
return this.EvaluateHasItem();
}
protected bool EvaluateHasItem()
{
ListBox _lstb = ( ( ListBox ) this.FindControl( this.ControlToValidate ) );
466

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

return (_lstb.Items.Count != 0);


}
protected override void OnPreRender( EventArgs e )
{
if ( this.EnableClientScript ) { this.ClientScript(); }
base.OnPreRender( e );
}
protected void ClientScript()
{
this.Attributes["evaluationfunction"] = "lb_verify";
StringBuilder sb_Script = new StringBuilder();
sb_Script.Append( "<script language=\"javascript\">" );
sb_Script.Append( "\r" );
sb_Script.Append( "\r" );
sb_Script.Append( "function lb_verify(val) {" );
sb_Script.Append( "\r" );
sb_Script.Append( "var val = document.all[document.all[\"" );
sb_Script.Append( this.ClientID );
sb_Script.Append( "\"].controltovalidate];" );
sb_Script.Append( "\r" );
sb_Script.Append( "if ( val != null ) {" );
sb_Script.Append( "\r" );
sb_Script.Append( "if (val.tagName == \"SELECT\") {" );
sb_Script.Append( "\r" );
467

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

sb_Script.Append( "var selCount = 0;\r" );


sb_Script.Append( "var i;\r" );
sb_Script.Append( "for(i=0;i<val.options.length;i++)\r" );
sb_Script.Append( "{\r" );
sb_Script.Append( "if(val.options[i].selected)\r" );
sb_Script.Append( "selCount++;\r" );
sb_Script.Append( "}\r" );
sb_Script.Append( "if ( selCount >= "
+ this._RequieredItem.ToString () + " ) {" );
sb_Script.Append( "\r" );
sb_Script.Append( "return true;" );
sb_Script.Append( "\r" );
sb_Script.Append( "}" );
sb_Script.Append( "\r" );
sb_Script.Append( "}" );
sb_Script.Append( "\r" );
sb_Script.Append( "\r" );
sb_Script.Append( "return false;" );
sb_Script.Append( "\r" );
sb_Script.Append( "}" );
sb_Script.Append( "\r" );
sb_Script.Append( "}" );
sb_Script.Append( "\r" );
sb_Script.Append( "</script>" );
this.Page.RegisterClientScriptBlock( "LSBScript", sb_Script.ToString() );
}
468

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

}
}
DLL ( DLL ) Assembly
VS.NET References
. .
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs"
AutoEventWireup="false" Inherits="WebApplication1.WebForm1" %>
<%@ Register TagPrefix="mylib" Namespace="MyLib" Assembly="MyLib" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="FlowLayout">
<form id="WebForm1" method="post" runat="server">
<asp:ListBox id="ListBox1" runat="server" SelectionMode="Multiple">
<asp:ListItem Value="1">Item 1</asp:ListItem>
<asp:ListItem Value="2">Item 2</asp:ListItem>
<asp:ListItem Value="3">Item 3</asp:ListItem>
</asp:ListBox>
469

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

<mylib:RequieredListBoxValidator id="RequieredListBoxValidator1"
runat="server" RequieredItem="2" ErrorMessage="You have to select at least 2 items
from list box!" ControlToValidate="ListBox1"></mylib:RequieredListBoxValidator>
<br>
<asp:Button id="Button1" runat="server" Text="Button"></asp:Button>
</form>
</body>
</HTML>

470

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ListBox ASP.NET

listbox Style
.
www.iranasp.net/download/ webtech038.zip :
ASP.NET
. ListBox
.

.
.
.
ListBox
:
1
471

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

;ListItem item
)for(int i = 1; i<=10; i++
{
;)( item = new ListItem
;)( item.Value = i.ToString
;)( item.Text = "Item" + i.ToString
;)"item.Attributes.Add ("Style", "background-color: #0000ff;color: #ffffff
;)myListBox.Items.Add (item
}
! Style ListItem
HTML render .
ASP.NET ListBox .

.
ASP.NET

.
ListBox
ASP.NET render .
ListBox!
Inheritance ) . )!
472

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

StyledListBox
ListBox . C# :
][C#
;using System
;using System.Collections
;using System.Web.UI
;using System.Web.UI.WebControls
namespace ColoredListBox
{
>/// <summary
/// Summary description for StyledListBox.
>/// </summary
public class StyledListBox : System.Web.UI.WebControls.ListBox
{
}
}
. ColoredListBox
. StyledListBox public
. ListBox ASP.NET
System.Web.UI.WebControls.ListBox ListBox
.

473

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

ListBox
ListBox .
. ListBox
. ListBox RenderContents
:
[C#]
using System;
using System.Collections;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace ColoredListBox
{
/// <summary>
/// Summary description for StyledListBox.
/// </summary>
public class StyledListBox: System.Web.UI.WebControls.ListBox
{
override protected void RenderContents(HtmlTextWriter writer)
{
for(int c=0;c<Items.Count;c++)
{
ListItem i = Items[c];
writer.WriteBeginTag("option");
474

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

if(i.Selected)
writer.WriteAttribute("selected","selected",false);
writer.WriteAttribute("value",i.Value,true);
IEnumerator d = Items[c].Attributes.Keys.GetEnumerator();
while(d.MoveNext())
writer.WriteAttribute(d.Current.ToString(),Items[c].Attributes[d.Current.ToString()]);
writer.Write('>');
System.Web.HttpUtility.HtmlEncode(i.Text,writer);
writer.WriteEndTag("option");
writer.WriteLine();
}
}
}
}
HtmlTextWriter !
.
Attribute selected value listbox
! ListBox HTML
:
[C#]
IEnumerator d = Items[c].Attributes.Keys.GetEnumerator();
while(d.MoveNext())
writer.WriteAttribute(d.Current.ToString(),Items[c].Attributes[d.Current.ToString()]);
475

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

ListBox .
ColoredListBox.StyledListBox listbox
. codebehind .
[C#]
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace ColoredListBox
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected StyledListBox ListBox1;
private void Page_Load(object sender, System.EventArgs e)
476

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

{
// Put user code to initialize the page here
ListItem item;
item = new ListItem ("IranASP.NET 1", "1");
item.Attributes.Add ("Style", "background-color:#39B54A; color:#ffffff");
this.ListBox1.Items.Add (item);
item = new ListItem ("IranASP.NET 2", "2");
item.Attributes.Add ("Style", "color:#0000ff");
this.ListBox1.Items.Add (item);
item = new ListItem ("IranASP.NET 3", "3");
item.Attributes.Add ("Style", "background-color:#ff0000; color:#ffffff");
this.ListBox1.Items.Add (item);
}
}
}
listbox aspx
StyledListBox .
:

<%@ Register TagPrefix="iranasp" Namespace="ColoredListBox"


Assembly="ColoredListBox" %>
477

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

User Control . listbox


:

><iranasp:StyledListBox id="ListBox1" runat="server"></iranasp:StyledListBox

!
: Style
listbox .

478

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

JavaScript ASP.NET

Server-Side Client-Side
.
ASP.NET ) Server-Side (
. JavaScript ) Client-Server (
.
! . JavaScript
JScript JavaScript JavaScript
. .
Server-Side Client-Side ASP.NET
. ASP.NET .
ASP.NET ASP.NET
.
.
Submit . ASP.NET
JavaScript __ doPostBack .
HTML . runtime
Render HTML .
1
479

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET
. ASP .NET ASP.NET

.
aspnet_client .
JScript ASP.NET
.
ASP.NET
. ASP.NET

.

Page
Page ASP.NET
)(Method .
:RegisterClientScriptBlock JavaScript
. ) (string key script
. script JavaScript key
. > <form
www.iranasp.net/tutorial/article.aspx@articleid=107 1
480

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

. HTML
. ASP.NET
HTML ( comment) JavaScrip
.
<script language="JavaScript">
<!-
// -->
</script>
.

[C#]
<html>
<head>
<script language="C#" runat="server">
public void Page_Load(Object sender, EventArgs e) {
// Form the script that is to be registered at client side.
String scriptString = "<script language=JavaScript> function DoClick() {";
scriptString += "myForm.show.value='Welcome to Microsoft .NET'}<";
scriptString += "/";
scriptString += "script>";
481

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

if(!this.IsClientScriptBlockRegistered("clientScript"))
this.RegisterClientScriptBlock("clientScript", scriptString);
}
</script>
</head>
<body topmargin="20" leftmargin="10">
<form id="myForm" runat="server">
<input type="text" id="show" style="width=200"> <input type="button"
value="ClickMe" onclick="DoClick()">
</form>
</body>
</html>
:IsClientScriptBlockRegistered
RegisterClientScriptBlock ( key)
RegisterClientScriptBlock .
.
RegisterClientScriptBlock :RegisterStartupScript
. .< form/>
[C#]
<html>
<head>
482

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

<script language="C#" runat="server">


public void Page_Load(Object sender, EventArgs e) {
// Form the script to be registered at client side.
String scriptString = "<script language=JavaScript> function DoClick() {";
scriptString += "showMessage2.innerHTML='<h4>Welcome to Microsoft
.NET!</h4>'}";
scriptString += "function Page_Load(){ showMessage1.innerHTML=";
scriptString += "'<h4>RegisterStartupScript Example</h4>'}<";
scriptString += "/";
scriptString += "script>";
if(!this.IsStartupScriptRegistered("Startup"))
this.RegisterStartupScript("Startup", scriptString);
}

</script>
</head>
<body topmargin="20" leftmargin="10" onload="Page_Load()">
<form id="myForm" runat="server">
<span id="showMessage1"></span>
<br>
<input type="button" value="ClickMe" onclick="DoClick()">
<br>
<span id="showMessage2"></span>
</form>
483

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

></body
></html
:IsStartupScriptRegistered
) (key RegisterStartupScript .
RegisterStartupScript
.
:GetPostBackClientEvent
)(Submit .
:GetPostBackEventReference GetPostBackClientEvent
) (Submit .
:GetPostBackClientHyperlink
) (Submit :javascript .
:RegisterOnSubmitStatement OnSubmit
. .
][C#
)void Page_Load(Object sender, EventArgs e
{
;"{ )(String scriptString = "<script language=JavaScript> function doClick
scriptString += "document.write('<h4>' + myForm.myHiddenField.value+
;"<};)'>'</h4
484

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

;">scriptString += "/" + "script


;)"!RegisterHiddenField("myHiddenField", "Welcome to Microsoft .NET
RegisterOnSubmitStatement("submit", "document.write('<h4>Submit button
;)")'>clicked.</h4
;)RegisterStartupScript("startup", scriptString
}


.

. static
) new
( . ) (namespace
(Common.PageUtil.MakeJavaScriptBlock).
.

;using System
;using System.Web.UI
;using System.Text
485

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

using System.Web.UI.WebControls;
namespace Common
{
/// <summary>
/// Utility class for ASP.NET pages
///
/// Be sure to notice that this code is provided as a technology sample
/// and 'as is' and no warranties are made by the author.
///
/// </summary>
public class PageUtil
{
// This static methods helps you build your JavaScript blocks easily
public static string MakeJavaScriptBlock(string strJavascript)
{
string sScript;
sScript = "\n<script language=\"javascript\">\n";
sScript += "<!--\n";
sScript += strJavascript;
sScript += "// -->\n";
sScript += "</script>\n";
return sScript;
}
// This staic method is used in popup screens
// to close popup after doing some thing
486

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

public static void CloseCurrent(System.Web.UI.Page page)


{
string sScript = "window.close();";
sScript = Common.PageUtil.MakeJavaScriptBlock (sScript);
page.RegisterStartupScript ("CloseCurrent", sScript);
}
public static void ShowAlert(string msg, System.Web.UI.Page page)
{
if (page.Request.Browser.JavaScript == true)
{
string sScript = "alert(\"" + msg + "\");\n";
sScript = Common.PageUtil.MakeJavaScriptBlock (sScript);
page.RegisterStartupScript ("ShowAlertScript", sScript);
}
}
}
}

487

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

DataList

DataList
. DataList
.
DataSource . DataList
DataBase DataBind DataSet Table
.
:
[Code Behind - VB.NET]
Dim Conn As New OleDbConnection
Dim Comm As New OleDbCommand
Dim ds As New DataSet
Dim adp As New OleDbDataAdapter
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Conn.ConnectionString = "Your ConnectionString"
Comm.CommandText = "Select Top 10 * from TableName"
Comm.Connection = Conn
adp.SelectCommand = Comm
1

488

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

adp.Fill(ds, "Blog")
Conn.Close()
DataList1.DataSource = ds.Tables("Blog").DefaultView
DataList1.DataBind()
End Sub
[HTML Code]
<asp:DataList Width="100%" id="DataList1" runat="server">
<ItemTemplate>
<font color="Orange"><%# databinder.Eval(container.dataitem,"RowName")
%></font>
</ItemTemplate>
</asp:DataList>
<ItemTemplate> . RowName HTML
< FooterTemplate> < HeaderTemplate> .
. Eval .
Happy DataListing!

489

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET

ASP.NET
.

ASP.NET .
.
ASP POST ASP
. ) ) ASP.NET
ASP.NET .
. :
Querystring
Session
Server.Transfer
Querystring
Querystring .
.

490

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

.
. :


Button LinkButton
String URL
.
QueryString String
Response.Redirect String

:

private void Button1_Click
)(object sender, System.EventArgs e
{
;string url
url="anotherwebform.aspx?name=" +
TextBox1.Text + "&email=" +
;TextBox2.Text

491

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

;)Response.Redirect(url
}

private void Page_Load
)(object sender, System.EventArgs e
{
;]"Label1.Text=Request.QueryString["name
;]"Label2.Text=Request.QueryString["email
}

Session
Session
. Session
. Session
. :

Button LinkButton
Session
Server.Transfer

492

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

. Session

:

private void Button1_Click
(object sender, System.EventArgs e)
{
//textbox1 and textbox2 are webform
//controls
Session["name"]=TextBox1.Text;
Session["email"]=TextBox2.Text;
Server.Transfer("anotherwebform.aspx");
}

private void Page_Load
(object sender, System.EventArgs e)
{
Label1.Text=Session["name"].ToString();
Label2.Text=Session["email"].ToString();
Session.Remove("name");
Session.Remove("email");
}
493

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Server.Transfer
.
.
. .

Get
Button LinkButton
Server.Transfer
Context.Handler
. Get .

:

:
public string Name
{
get
{
;return TextBox1.Text
494

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

}
}
public string EMail
{
get
{
return TextBox2.Text;
}
}
. Server.Transfer
private void Button1_Click
(object sender, System.EventArgs e)
{
Server.Transfer("anotherwebform.aspx");
}

private void Page_Load
(object sender, System.EventArgs e)
{
//create instance of source web form
WebForm1 wf1;
//get reference to current handler instance
wf1=(WebForm1)Context.Handler;
495

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

Label1.Text=wf1.Name;
Label2.Text=wf1.EMail;
}
:
http://www.iranasp.net/Articles/ShowArticle.aspx?articleid=102

496

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

DataGrid

DataGrid
www.iranasp.net/download/evalizadeh003.zip:

DataGrid NET Framework. .


.
.
DataGrid .
products products.mdb .
) ImageName (Text .
DataGrid
DataSet DataGrid ) (Bind
.
DataGrid
DataGrid . DataGrid
AutoGenerateColumns False .
DataGrid . DataGrid :

497

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

. : BoundColumn
. Hyperlink : HyperLinkColumn
. : TemplateColumn
. Button : ButtonColumn
. Cancel Update Edit : EditCommandButton

: DataGrid
<asp:Datagrid id="dg" runat="server" AutoGenerateColumns="False"
BorderColor="Black" Font-Size="10" Font-Name="Arial" BackColor="#C6C3FF"
Headerstyle-Font-Size="12" Headerstyle-Font-Bold="True" Headerstyle-FontName="Arial" Headerstyle-Forecolor="#0F0F0F" Headerstyle-BackColor="#8482C6"
cellspacing="0" cellpadding="0" GridLines="Both">
<columns>
<asp:BoundColumn HeaderStyle-HorizontalAlign="Center" DataField="ProdName"
HeaderText="ProdName"></asp:BoundColumn>
<asp:TemplateColumn HeaderStyle-HorizontalAlign="Center">
<HeaderTemplate>
Images
</HeaderTemplate>
<ItemTemplate>
<div align="center">
<img src='/prodimages/<%# Container.DataItem("ImageName") %>'
498

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

>border="0" /
></div
></ItemTemplate
></asp:TemplateColumn
"<asp:BoundColumn DataField="Comments
>HeaderText="Comments"></asp:BoundColumn
></columns
></asp:Datagrid
DataGrid .
BoundColumn TemplateColumn BoundColumn
. BoundColumn
DataField DataGrid .
DataGrid.
"<asp:BoundColumn HeaderStyle-HorizontalAlign="Center
>DataField="ProdName" HeaderText="ProdName"></asp:BoundColumn
TemplateColumn DataGrid

TemplateColumn . TemplateColumn DataGrid
:
: HeaderTemplate .
: ItemTemplate .
499

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

EditItemTemplate: .
FooterTemplate: .

DataGrid HeaderTemplate ItemTemplate


. HeaderTemplate Images
. ItemTemplate .
HTML .
>"<div align="center
><img src='/prodimages/<%# Container.DataItem("ImageName") %>' border="0" /
></div
> <img prodimages .
> <%# Container.DataItem("ImageName") %
ImageName .

products.mdb
.

500

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

DataGrid

Hotmail Yahoo
.
checkbox . ASP.NET
. DataGrid ASP.NET
.
DataGrid .
www.iranasp.net/download/szhooshmand001.zip :

Datagrid )
ID( . Datagrid checkbox
.

. DataTable
firstname lastname String ID Integer
. DataTable .

501

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

Private Function generateDataSource() As DataTable


Dim dt As New DataTable
dt.Columns.Add(New DataColumn("FirstName", Type.GetType("System.String")))
dt.Columns.Add(New DataColumn("LastName", Type.GetType("System.String")))
dt.Columns.Add(New DataColumn("ID", Type.GetType("System.Int32")))
Dim dr As DataRow
dr = dt.NewRow
dr.Item(0) = "Salman"
dr.Item(1) = "Zoroofi"
dr.Item(2) = "1"
dt.Rows.Add(dr)
dr = dt.NewRow
dr.Item(0) = "Ali"
dr.Item(1) = "Mohammadi"
dr.Item(2) = "2"
dt.Rows.Add(dr)
dr = dt.NewRow
dr.Item(0) = "Reza"
dr.Item(1) = "Maghsoodi"
dr.Item(2) = "3"
dt.Rows.Add(dr)
dr = dt.NewRow
dr.Item(0) = "Maryam"
dr.Item(1) = "Moosavi"
dr.Item(2) = "4"
dt.Rows.Add(dr)
dr = dt.NewRow
502

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

dr.Item(0) = "Ehsan"
dr.Item(1) = "Mojtahedi"
dr.Item(2) = "5"
dt.Rows.Add(dr)
Return dt
End function
) DataTable dt DataTable
.( Page_load
Private dt As DataTable
dt . Page_Load
. Datagrid
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
DataGrid1.AllowPaging = True
DataGrid1.PageSize = 3
If Not IsPostBack Then
dt = generateDataSource()
viewstate.Add("dt", dt)
DataGrid1.DataSource = dt
DataGrid1.DataBind()
Else
dt = CType(viewstate("dt"), DataTable)
DataGrid1.DataSource = dt
503

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

End If
End Sub
Datagrid
Datagrid Property Builder .
Columns Available Columns Template Column
< Selected Columns . Header text
Select . OK . checkbox .
Datagrid Edit Template ] Select - Column [0 .
checkbox Item Template .
End template editing .

DataGrid DataGrid DataBind
Datasource . DataSource
Databind ). (
Databind DataBind
Datagrid .
ID
. ID . ID
arraylist arrselected .
504

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

Public Shared arrselected As New ArrayList


shared
.( postback)
: Datagrid PreRender DataBinding
PreRender ( load ) DataBind ) ( DataBind
DataBinding ID . Datagrid HTML
.( arrselected ) arrselected
rivate Sub DataGrid1_DataBinding(ByVal sender As Object, ByVal e As
System.EventArgs) Handles DataGrid1.DataBinding
For Each i As DataGridItem In DataGrid1.Items
'add
If CType(i.FindControl("checkbox1"), CheckBox).Checked AndAlso Not
arrselected.Contains(i.Cells(3).Text) Then
arrselected.Add(i.Cells(3).Text)
End If
'remove
If Not CType(i.FindControl("checkbox1"), CheckBox).Checked Then
arrselected.Remove(i.Cells(3).Text)
End If
Next
End sub

505

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

arrayselected ID Datagrid prerender ID


. checkbox ID
Private Sub DataGrid1_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles DataGrid1.PreRender
For Each i As DataGridItem In DataGrid1.Items
If arrselected.Contains(i.Cells(3).Text) Then
CType(i.FindControl("checkbox1"), CheckBox).Checked = True
End If
Next
End Sub
sort Datagrid
.
. code behind
Private Sub DataGrid1_PageIndexChanged(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles
DataGrid1.PageIndexChanged
DataGrid1.CurrentPageIndex = e.NewPageIndex
DataGrid1.DataBind()
End Sub

www12.brinkster.com/salmanzh/newfile.aspx

506

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Datagrid . template
column checkbox Datagrid . DataBinding
PreRender
Datagrid .

507

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

DataSet

ADO.NET : DataSet DataReader.


. DataReader
DataSet
DataSet . DataSet
.
www.iranasp.net/download/evalizadeh006.zip
DataSet
DataSet

.
DataSet :

- 1 DataGrid
- 2 DataList
- 3 Repeater
- 4

508

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

DataSet . DataTable DataSet


: DataSet . DataAdapter

: Connection
Dim strConn as string = initial catalog=Northwind;integrated
security=SSPI;persist security info=False;workstation id=DOTNET"
Dim MyConn as New SQLConnection(strConn)
DataSet:
Dim ds as DataSet=New DataSet()
DataAdapter:
Dim MySQL as string = "Select Employees.FirstName, Employees.LastName,
Employees.Title from Employees"
Dim da as New SQLDataAdapter(MySQL,MyConn)
: DataAdapter Fill
da.Fill(ds,"Employees")
DataTable DataSet
.

509

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

DataSet DataAdapter .
DataSet :
- 1DataGrid
Employees ) DataSet ( DataGrid
:
MyDataGrid.Datasource=ds.Tables("Employees").DefaultView
)(MyDataGrid.DataBind
Datasource DataGrid -
Employees DataSet - DataGrid
DataBind .
- 2DataList
DataList Repeater DataGrid
:
MyDataList.Datasource=ds.Tables("Employees").DefaultView
)(MyDataList.DataBind
- 3 Repeater

510

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

MyRepeater.datasource = ds.Tables("Employees").DefaultView
)(MyRepeater.DataBind
DataList DataGrid Repeater DataBound .
DataBound Programmatically .
.
.

. DataGrid
. Visual Studio .NET Auto Format
) DataGrid (DataList . DataList
DataGrid .
Repeater DataList
.
DataList Repeater
) DataGrid
( . DataList :
"<asp:DataList id="MyDataList" runat="server" GridLines="None
cellpadding="2" cellspacing="2" Headerstyle-BackColor="#8080C0" Headerstyle-FontName="Arial" Headerstyle-Font-Size="8" Font-Name="Arial" Font-Bold="false" Font>"Size="8
511

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "firstname") %> <%#
DataBinder.Eval(Container.DataItem, "lastname") %> <b><i><%#DataBinder.Eval(Container.DataItem, "Title") %> </i></b>
</ItemTemplate>
</asp:DataList>
data-binding DataBinder.Eval
: .
<%# DataBinder.Eval(Container, EvalExpression, FormatExpression) %>

DataBound Container
. EvalExpression Container Container.DataItem
FormatExpression
.
DataSet - 4
. DataSet
: . String DataSet
Dim sEmps as String
Dim dr As DataRow
For Each dr In ds.Tables("Employees").Rows
512

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

)"sEmps += "<b>" & dr("firstname") & " " & dr("lastname") & " </b> - " & dr("Title
">& "<br
Next
For
Each Next String . text
literal :
litEmps.text=sEmps

513

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com


. WinForm
.

.
.

.
: Windows Control Library Web Control Library.
.
)(UserControl1.cs .


.

514

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

public class ControlName : System.Windows.Froms.Panel


{
...
(Property)

.
private System.Windows.Forms.Border3DSide borderSide;
public System.Windows.Forms.Border3DSide BorderSide
{
get { return this.borderSide; }
set
{
if ( this.borderSide != value )
{
this.borderSide = value;
this.Invalidate(); // force repaint control at design time
}
}
}
.

515

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

public ControlName
{
this.borderSide = System.Windows.Froms.Boder3DSide.All;
this.border3DStyle = System.Windows.Froms.Border3DStyle.Etched;
}
(override)

.
protected override void OnPaint(System.Windows.From.PaintEventArgs e)
{
base.OnPaint(e);
System.Windows.Froms.ControlPaint.DrawBorder3D (
e.Graphics,
this.ClientRectangle,
this.border3DStyle,
this.borderSide );
}
Object Browse
. Add Override

516

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com


Properties
.
:Bindable true
designer )
( .
:DefualtValue
.
:Category
Properties .
:Description
Properties .
:ReadOnly true
.
:Editor . Editor
Editor ) (.

517

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

[Bindable(true), Category("Border Options"),


DefaultValue(System.Windows.Forms.Border3DSide.All),
Description("Specifies the sides of the panel to
apply a three-dimensional border to.")]
public System.Windows.Forms.Border3DSide BorderSide
{
...

518

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com


. WinForm
.

.
.
Design .
UITypeEditor .
EditValue GetEditStyle . EditValue
. .
.
public class StringEditor : System.Drawing.Design.UITypeEditor
{
public override object EditValue(ITypeDescriptorContext context,
)IServiceProvider serviceProvider, object value
{
))if ((context != null) && (serviceProvider != null
{

519

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

//Set the editor service


IWindowsFormsEditorService edSvc =
(IWindowsFormsEditorService)serviceProvider.GetService(
typeof(IWindowsFormsEditorService));
if (edSvc != null)
{
//Create new designed form
DesignedForm form = new DesignedForm();
form.Value = (string)value;
//Show form as a dialog
DialogResult result = edSvc.ShowDialog(form);
if (result == DialogResult.OK)
{
value = form.Value;
}
}
}
return value;
}
public override UITypeEditorEditStyle GetEditStyle( ITypeDescriptorContext
context)
{
if (context != null) {
//The editor will be a modal window.
return UITypeEditorEditStyle.Modal;
520

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

}
;)return base.GetEditStyle(context
}
}
Editor
.
[Editor(typeof(StringEditor),
]))typeof(UITypeEditor
public string ServerUrl
{
...
enum
enum .
enum
ListboxTypeEditor FillInList
. .
public class FormatListboxTypeEditor : ListboxTypeEditor
{
protected override void FillInList(ITypeDescriptorContext context,
)IServiceProvider provider, ListBox listBox
{
;)"listBox.Items.Add("Item 1
521

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

;)"listBox.Items.Add("Item 2
;)"listBox.Items.Add("Item 3
;listBox.BorderStyle = BorderStyle.None
}
}

)(ToolBox
.
.
Bitmap 16 16*16 .
Build Action Embedded Resource .
ToolboxItem ToolboxBitmap .
])[ToolboxItem(true
]))[ToolboxBitmap(typeof(ImageName
public class DividerPanel : System.Windows.Forms.Panel
{
...

Designer

522

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

.
.
public class ControlNameDesigner :
System.Windows.Forms.Design.ScrollableControlDesigner
{
}

. PreFilterProperties
protected override void PreFilterProperties(
System.Collections.IDictionary properties)
{
properties.Remove("BorderStyle");
}
Designer DesignerAttribute
.
[DesignerAttribute(typeof(ClassNameDesigner))]
public class ControlName : System.Windows.Forms.Panel
{
...

523

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

Assembly
. assembly
AssemblyInfo.cs .
.
[assembly: AssemblyTitle("Control Title")]
[assembly: AssemblyDescription("Control Description")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Company")]
[assembly: AssemblyProduct("Product Name")]
[assembly: AssemblyCopyright("Copyright Info")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

.
// Flagging your assembly with the CLS Compliant attribute
// lets the Framework know that it will work with all
// CLS Compliant languages, and theoretically with all
// future framework platforms (such as Mono on Linux).
// If possible you should avoid using any non-CLS compliant code
// in your controls such as unsigned integers (uint) and
// calls to non-framework assemblies.
[assembly: System.CLSCompliant(true)]
524

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

m.bashiry@gmail.com

ASP.NET

// The ComVisible attribute should always be explicitly set for controls.


// Note that in order for your control to be consumed by
// COM callers, you must use parameter-less constructors
// and you cannot use static methods.
[assembly: System.Runtime.InteropServices.ComVisible(true)]
assembly . assembly
. download
Visual Studio.NET Command Prompt Strong Name
. assembly /
sn -k [outputfile].snk
. assembly
[assembly: AssemblyKeyFile("..\\..\\..\\outputfile.snk")]

525

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

:ASP.NET 2.0
Master Page

ASP.NET 2.0 .
Master Page .
. Master Page
.
.

. .
" .
ASP.NET User Control
) User Control ( . User
Control aspx
.
) ASP.NET 2 ( Master Page
. Master
Page ASP.NET 2 Web Developer 2005 Express Edition .
.
Shahabfar.com Iranian .NET Community 1

526

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Web Developer 2005 Express Edition The .NET Framework 2 beta-

:
Web Developer ASP.NET 2
.
- 1 Web Dev New Web Site New Web
Site .
- 2 Project Types ) C#
( .
.
- 3 Visual Studio installed templates ASP.NET Web Site .
- 4 Location . "
C:\WebSite\WebSite1
Web Dev Default.aspx .
Master Page.
527

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Master Page
Master Page
. Master Page . table
footer .
Content Placeholder
Master Page .
: Master Page
- 1 Solution Explorer Add
New Item .
- 2 Visual Studio Installed Templates Master Page
Master1.
- 3 Place code in separate file Code
behind .
- 4 Language .
Master Page Source View .
. body asp.contentplaceholder
528

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Master Page runtime .


.

Master Page
Master Page aspx . Master Page
. Master Page
ContentPlaceholder .
.
table Master Page
. ContentPlaceHolder Master Page
table .
table Master Page .
- 1 Design View Master Page.
- 2 Master Page BgColor
.
- 3 Layout Insert Table .

529

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

- 4 Insert Table Tamplate . Header, footer


and side .
- 5 table . 80
80 80
- 6 table VAlign top
.

Master Page .
- 1 Copyright
.
- 2 Navigation toolbox Menu table
) ASP.NET 2 .
Menu" ( .
Orientation Menu Horizontal . Common
Menu Task Menu Edit Menu Items
.
- 3 Items
. Text Home NavigationUrl
530

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Home.aspx . Text About NavigationUrl


About.aspx .
- 4 table .

ContentPlaceHolder :
- 1 ContentPlaceHolder table
.
- 2 .

Maste Page
ASP.NET Master Page . Master
Page . aspx Master Page
. " home
about .
home.aspx :
- 1 Solution Explorer Add New Item
.
531

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

- 2 Visual Studio Installed Templates Web Form .


- 3 Home .
- 4 Language .
- Select Master Page 5 Add Select a Master Page
.
- 6 Master1.master ok .
home .

532

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Master Page
. .
home.aspx .
ContentPlaceHolder CreateCustomContent
. ContentPlaceHolder Welcome to my website
.
about.aspx home .
Ctrl+F5 .

533

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

ASP.NET home about Master Page .


ASP.NET 2 Localhost
.
MSDN:

534

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

:ASP.NET 2.0
Master Page

Master Page
ASP.NET 2.0 .
Master Page .
.
.
Master Page ."
.
Master Page .
Master Page .
Master Page
button Master Page . Master Page
.
:
- 1 Solution Explorer Master1.master .

Shahabfar.com Iranian .NET Community 1

535

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

- 2 paste .

- Master Page 3 Master2.master .

- 4 Master2.master Html @Master Master1 Master2


.

"Master Language="C#" CompileWith="Master2.master.cs


"@ClassName="Master2_master
- 5 Design View .

- 6 properties DOCUMENT
.

- 7 BgColor .

- Master Page 8 Master1_master


Master2_master .

button Master Page :

536

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

- 1 LinkButton Master2.master
" Change to MP1

- 2 button . .
)void LinkButton1_Click(object sender, EventArgs e
{
;"Session("masterpage") = "MasterPage1.master
;))(Response.Redirect(Request.Url.ToString
}
Master Page Session
.
- 3 Master1.master LinkButton
Change to MP2 .

- 4 .
)void LinkButton1_Click(object sender, EventArgs e
{
537

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

;"Session("masterpage") = "MasterPage2.master
;))(Response.Redirect(Request.Url.ToString
}
- 5 About.aspx .
- 6 Page_PreInit .
[Session[masterpage
Me.MasterPageFile . " Page_PreInit .
WebForm Master Page .
Page_PreInit . Page_Init Page_Load
Page_PreInit .

CTRL+F5 -1 home browser .

- 2 About Chage to MP2 . About


Master2.master .
- 3 Change to MP1 . About Master1.master .

538

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

Master Page .
MSN.com
. Master Page
.
Web Developer 2005 Express Edition (ASP.NET 2) beta
www.shahabfar.com/express
MSDN:

539

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

User Control

User Control ASP.NET


. UC html
aspx UC .
UC
Handle . .
www. iranasp.net/download/shahabfar003.zip :
UC ) (User Control ASP.NET
. UC html aspx
UC .
Web Form UC Cache (Fragment Caching). UC
. UC Method
Property .
Event .
. Button
UC .
UC . UC
. UC .

Shahabfar.com Iranian .NET Community 1

540

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

UC .
Event .
.
UC .
. Event
UC .
) (Data Bound DataList Repeater DataGrid .
DataList .
DataList .
.
UC SelectionChangedEventArgs
. System.EventArgs .
.
.
UC .
public class SelectionChangedEventArgs : EventArgs
{
;public int SelectedIndex
}

541

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

delegate . delegate
. delegate .
public delegate void SelectionChangedEventHandler(object sender,
;)SelectionChangedEventArgs e
;public event SelectionChangedEventHandler SelectionChanged
.

DataList UC . .
Event . .
)public void SelectMenuItem(int index
{
;)(dlMenu.DataBind
;)(SelectionChangedEventArgs ev = new SelectionChangedEventArgs
;ev.SelectedIndex = index
)if(SelectionChanged != null
;)SelectionChanged(this, ev
}
DataList .

. null SelectionChanged

542

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

SelectionChangedEventHandler delegate .
.
.

543

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

) (User Control
LoadControl
ASP.net .
HTML net. . .ascx
aspx tag
.
"<%@ Register TagPrefix="uc1" TagName="HeaderUserControl
>Src="HeaderUserControl.ascx" %
...
><uc1:HeaderUserControl id="Header1" runat="server"></uc1:HeaderUserControl
load . Page_Load
Button_Click . !
.net LoadControl )
tag html ASP. net .net ( .
FeaturedProduct.ascx . :

544

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

;)"Control FeaturedProductUserControl = LoadControl("FeaturedProduct.ascx


;)Controls.Add(FeaturedProductUserControl


place holder's controls collection . :
;)PlaceHolderLeftMenu.Controls.Add(FeaturedProductUserControl

CMS
IBuySpy .
ASPAlliance:

545

Ramin.samad@yahoo.com

WWW.IRANMEET.COM

ASP.NET

m.bashiry@gmail.com

.

.
m.bashiry@gmail.com
mohamad_bashiry@gmail.com
m_bashiry@walla .com

546

Ramin.samad@yahoo.com

Vous aimerez peut-être aussi