استفاده از مطالب این صفحه با ذکر نام  این سایت بلا مانع می باشد.
 

آموزش ASP : مبتدی

باسلام

جلسه دوم   : توجه :کلمات MIAT EL.ORG جزو آموزش نمی باشند:

 

توضیحات:شاید عمده ترین کاربرد توضیخات دربرنامه را بتوان یاد اوری کد نوشته شده بعد از مدتها دانستبرای  نوشتن توضیحا در یک فایلASPاز ' استفاده می کنند در زیر توضیحات با رنگ سبز مشخص شده اند

<%
'This is a comment, below I will write out my name
response.write "Michael Wall"
%>

<%
response.write "Michael Wall" ' This will write out my name 'Michael Wall
'note that the apostrophe above didn't start on a new line and it 'doesn't have too
%>

 

اولین برنامه ASP شما:

کد روبرو را در NOTPAD   تایپ کرده و با نام helloworld.asp  در  C:\inetpub\wwwroot\ASP folderذخیره نمایید سپس اکسپلورر را باز کرده و دستور زیر را تایپ کنید

http://localhost/asp/helloworld.asp

 

MIATEL.O RG

<%@ Language="VBscript" %>

<% Dim I ' declare a variable I which will act as our loop counter variable
' Start the loop which will loop from 1 to 5 incrementing I by one each time
For I = 1 To 5 ' FONT TAG's SIZE attribute will be determined by the value of I
' so on the first loop the font tag's size will be 1 and on the last loop it will be 5.

%>

<font size="<% response.write(I) %>">Hello World</font>
<br>
<%

Next ' repeat the loop again only if it hasn't passed through 5 yet.
%>

بعد از اجرا ء، خواهید داشت:

 MIAT EL.ORG

 

delimiters(مشخص کننده های  ASP):

برای اینکه کدهای یک فایل asp را درون یک فایل html مشخص کنید نیاز دارید تا از مشخص کننده ها استفاده نمایید مشخص کننده ها <%  کد asp  %> میی باشند

<% If request.form("name") <>"michael" then
response.write "your name is not michael"
End if %>

نکته: دو وستور فوق معادلند

<%= "michael" %>
or
<% response.write "michael" %>

 

MIATEL.O R Gهنگامی که اجرای دستورالعملی منوط به برقراری شرطی باشد از دستور زیراستفاده می کنیم

If Condition Then
statement
End If

در مثال روبرو چون مقدار دو متغیر A,Bبرابر است پیغام"A is equal to B در صفحه اکسپلورر نمایش داده خواهدشد

<%
Dim A, B ' declare our variables
A=2
B=2
If A=B Then
response.write "A is equal to B"
End If
%>

 

 هنگامی که از بین دو دستور که منوط به شرطی است بخواهیم یکی رااجرا کنیم از دستو ر زیر استفاده می کنیم :

If Condition Then
statement
Else
statement
End If

در مثال روبرو چون مقدار دو متغییر A,Bبرابرنیست پیغام A is not equal to Bنمایش داده می شود .

<%
Dim A, B ' declare our variables
A=2
B=3
If A=B Then
response.write "A is equal to B"
Else
response.write "A is not equal to B"
End If
%>