Saturday, February 23, 2013

Get in ASP

<!DOCTYPE html>
<html>
    <body>
        <form method="GET" action="get.asp">
            Name: <input type="text" name="name">
            <input type="submit" value="Save">
        </form>
    </body>
</html>

<%
    response.write("Your name is "& Request.QueryString("name"))
%>

String Length in ASP

<!DOCTYPE html>
<html>
    <body>
        <%
            name = "Rakib"
            response.write(Len(name))
        %>
    </body>
</html>

If statement in ASP

<!DOCTYPE html>
<html>
    <body>
        <%
            x=5
            y=5

            if x>y then
                response.write("x is greater than y")
            elseif x<y then
                response.write("x is less than y")
            else
                response.write("x is equal to y")
            end if
        %>
    </body>
</html>

Break in ASP

<!DOCTYPE html>
<html>
    <body>
        <%
            For i=0 to 10
                if(i=5) then exit for
                response.write(i)
            Next
        %>
    </body>
</html>

Function in ASP

<!DOCTYPE html>
<html>
    <body>
        <%
            Function add(x,y)
                res = x + y
                add = res
            End Function
           
            response.write(add(2,4))
        %>
    </body>
</html>

Printing even number in ASP

<!DOCTYPE html>
<html>
    <body>
        <%
            For i=0 to 10
                if(i mod 2=0) then response.write(i)
            Next
        %>
    </body>
</html>

For Loop in ASP

<!DOCTYPE html>
<html>
    <body>
        <%
            For i=0 to 10 step 2
                response.write(i)
            Next
        %>
    </body>
</html>