Está en la página 1de 4

Generated by Foxit PDF Creator © Foxit Software

http://www.foxitsoftware.com For evaluation only.

21.- Capturando caracteres de una variable

<html>
<body>

<%
texto="Bienvenido a AspTutor!!"
response.write(Mid(texto, 9, 2))
%>

</body>
</html>

22.- Llamadas a procedimientos


<html>

<head>
<%
sub vbproc(num1,num2)
response.write(num1*num2)
end sub
%>
</head>

<body>
<p>
El resultado del calculo es: <%call vbproc(3,4)%>
</p>
<p>
Tambien puedes llamar al procedimiento sin call
</p>
<p>
El resultado del calculo es: <%vbproc 3,4%>
</p>
</body>

</html>

23.- Formularios (metodo GET)

<html>
<body>

<form action="23basic.asp" method="get">


Pon tu nombre:
<input type="text" name="fname"><br><br>
<input type="submit" value="Submit">
</form>

<%
If Request.QueryString("fname")<>"" Then
Response.Write ("Hola " & Request.QueryString("fname") & "!")
Response.Write ("<br>¿Como estas hoy?")
End If
%>

</body>
</html>
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.

24.- Formularios (metodo POST)

<html>
<body>

<form action="24basic.asp" method="post">


Pon tu nombre:
<input type="text" name="fname"><br><br>
<input type="submit" value="Submit">
</form>

<%
If Request.form("fname")<>"" Then
Response.Write ("Hola " & Request.form("fname") & "!")
Response.Write ("<br>¿Como estas hoy?")
End If
%>

</body>
</html>

25.- Radio button en formularios

<html>
<body>
<%
dim telefono
telefono=Request.Form("telefono")
%>

<form action="25basic.asp" method="post">


<p>Selecciona tu telefono favorito:</p>
<input type="radio" name="telefono"
<%if telefono = "Samsung" then Response.Write("checked")%>
value="Samsung"> Samsung SGH 2100
<br>
<input type="radio" name="telefono"
<%if telefono = "Nokia" then Response.Write("checked")%>
value="Nokia"> Nokia 3330
<br>
<input type="submit" value="Submit">
</form>
<%
if telefono<>"" then
Response.Write("<p>Tu telefono favorito es: " & telefono & "</p>")
end if
%>

</body>
</html>

26.- Creando una cookie de bienvenida

<%
response.cookies("NumVisits").Expires = date + 365
num=request.cookies("NumVisits")

If num = "" Then


response.cookies("NumVisits") = 1
Else
response.cookies("NumVisits") = num + 1
End If
%>

<html>
<body>
<%
if num="" then
%>
Bienvenido! Esta es la primera vez que visitas esta pagina web.
<%
else
%>
Tu has visitado esta pagina web <%response.write(num)%> veces
<%
end if
%>
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.

</body>
</html>

27.- Como hacer Un Redirect hacia otra URL

<%
if Request.Form("select")<>"" then
Response.Redirect(Request.Form("select"))
end if
%>

<html>
<body>

<form action="27basic.asp" method="post">

<input type="radio" name="select"


value="1basic.asp">
Ejemplo basico 1<br>

<input type="radio" name="select"


value="2basic.asp">
Ejemplo basico 2<br><br>
<input type="submit" value="Ir">

</form>

</body>
</html>

28.- Controlando el buffer de ejecución

<%
Response.Buffer=true
%>
<html>
<body>
<p>Escribimos texto, pero este no se manda al cliente hasta que no invoquemos el
flush.</p>
<p>Este txto sigue sin mandarse, esta aqui guardadito</p>
<p>Vale, ya tenemos generado todo el texto que queriamos mandar,<br>
ahora hacemos flush al buffer y lo mandamos</p>
<%
Response.Flush
%>
</body>
</html>

29.- Limpiando el buffer de ejecución

<%
Response.Buffer=true
%>
<html>
<body>
<p>Escribimos texto, pero este no se manda al cliente hasta que no invoquemos el
flush.</p>
<p>Este texto sigue sin mandarse, esta aqui guardadito</p>
<p>Lo he pensado mejor, no voy a mandar el texto,<br>
ahora hacemos Clear al buffer y lo eliminamos</p>
<%
Response.Clear
%>
<p>Este texto, como esta despues del clear, si llega al cliente</p>
</body>
</html>
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.

30.- Terminar una script en medio del proceso

<html>
<body>
<p>Estoy escribiendo un texto en el cliente pero ......<br>
<%
Response.End
%>
Como hemos invocado un .End, se corta </p>
</body>
</html>

31.- Pasando información en un link

<html>
<body>

<a href="31basic.asp?color=azul">Ejemplo</a><br>

<%
Response.Write(Request.QueryString)
%>

</body>
</html>

32.- ¿qué tamaño tiene un envio?

<html>
<body>

<form action="32basic.asp" method="post">


Introduce un texto:
<input type="text" name="txt"><br><br>
<input type="submit" value="Submit">
</form>

<%
If Request.Form("txt")<>"" Then
Response.Write("Has escrito: ")
Response.Write(Request.Form)
Response.Write("<br><br>")
Response.Write("Bytes Totales enviados: ")
Response.Write(Request.Totalbytes)
End If
%>

</body>
</html>

También podría gustarte