Código fuente de 'Mensajes personalizados.asp'

<HTML>

<head>
<title>Mensajes personalizados - Códigos asp, programacion asp, descargas asp, rutinas asp</title>
</head>
<body style="font-family: Arial; font-size: 11pt">
<center><b><font face="Arial" size="3">Mensajes personalizados</font>
</b></center><br>


<BODY>

<SCRIPT LANGUAGE="VBScript">
<!--
Option Explicit

Sub cmdCreate_OnClick
  Dim strSub, strInput, strTitle, strText
  Dim Events
  Dim Buttons, Icon, Var, x
  Dim strDocString

  Select Case Document.Box.Sub.Value
  Case 1: strSub = "Sub cmdButton_OnClick()"
          strInput = "&#60;INPUT TYPE=&#34;BUTTON&#34; NAME=&#34;cmdButton&#34; VALUE=&#34;Púlsame&#34;&#62;<BR><BR>"
  Case 2: strSub = "Sub imgImage_OnClick()"
          strInput = "&#60;IMG SRC=&#34;????????.gif&#34; NAME=&#34;imgImage&#34;&#62;<BR><BR>"
  Case 3: strSub = "Sub Window_OnLoad()"
          strInput = ""
  Case 4: strSub = "Sub Window_OnUnLoad()"
          strInput ""
  End Select  

  strTitle = Document.Box.Title.Value
  strText = Document.Box.Text.Value
  Buttons = Int(Document.Box.Buttons.Value)
  Icon = Int(Document.Box.Icon.Value)

  If Buttons > 0 Then
    Select Case Buttons
      Case 1: Events = "&nbsp;&nbsp;If Answer = 1 Then" & vbCRLF & "&nbsp;&nbsp;' Código para OK<BR>" & vbCRLF _
                     & "&nbsp;&nbsp;If Answer = 2 Then" & vbCRLF & "&nbsp;&nbsp;' Código para CANCELAR<BR>" & vbCRLF
      Case 2: Events = "&nbsp;&nbsp;If Answer = 3 Then" & vbCRLF & "&nbsp;&nbsp;' Código para ABORTAR<BR>" & vbCRLF _
                     & "&nbsp;&nbsp;If Answer = 4 Then" & vbCRLF & "&nbsp;&nbsp;' Código para REINTENTAR<BR>" & vbCRLF _
                     & "&nbsp;&nbsp;If Answer = 5 Then" & vbCRLF & "&nbsp;&nbsp;' Código para IGNORAR<BR>" & vbCRLF
      Case 3: Events = "&nbsp;&nbsp;If Answer = 6 Then" & vbCRLF & "&nbsp;&nbsp;' Código para SÍ<BR>" & vbCRLF _
                     & "&nbsp;&nbsp;If Answer = 7 Then" & vbCRLF & "&nbsp;&nbsp;' Código para NO<BR>" & vbCRLF _
                     & "&nbsp;&nbsp;If Answer = 2 Then" & vbCRLF & "&nbsp;&nbsp;' Código para CANCELAR<BR>" & vbCRLF
      Case 4: Events = "&nbsp;&nbsp;If Answer = 6 Then" & vbCRLF & "&nbsp;&nbsp;' Código para SÍ<BR>" & vbCRLF _
                     & "&nbsp;&nbsp;If Answer = 7 Then" & vbCRLF & "&nbsp;&nbsp;' Código para NO<BR>" & vbCRLF
      Case 5: Events = "&nbsp;&nbsp;If Answer = 4 Then" & vbCRLF & "&nbsp;&nbsp;' Código para REINTENTAR<BR>" & vbCRLF _
                     & "&nbsp;&nbsp;If Answer = 2 Then" & vbCRLF & "&nbsp;&nbsp;' Código para CANCELAR<BR>" & vbCRLF
    End Select
  End If

  Var = Buttons + Icon

  strDocString = NewDocString(strSub, strInput, strTitle, strText, Var, Events)

  Document.Open
  Document.Writeln strDocString
  Document.Close
  Document.Clear
End Sub

Function NewDocString(strSub, strInput, strTitle, strText, Var, Events)

       NewDocString = "<html>" & vbCRLF _
       & "" & vbCRLF _
       & "<body>" & vbCRLF _
       & "<B>Este es el código:</B><BR><BR>" & vbCRLF _
       & "&#60;HTML&#62;<BR>" & vbCRLF _
       & "&#60;BODY&#62;<BR><BR>" & vbCRLF _
       & "&#60;SCRIPT LANGUAGE=&#34;VBSCRIPT&#34;&#62;<BR>" & vbCRLF _
       & "&#60;!--<BR>" & vbCRLF _
       & "Dim Answer<BR>" & vbCRLF _
       & strSub & "<BR>" & vbCRLF _
       & "&nbsp;&nbsp;Answer = MsgBox (&#34;" & strText & "&#34;, " & Var & ", &#34;" & strTitle & "&#34;)<BR>" & vbCRLF _
       & Events & vbCRLF _
       & "End Sub<BR>" & vbCRLF _
       & "//--&#62<BR>" & vbCRLF _
       & "&#60;/SCRIPT&#62;<BR><BR>" & vbCRLF _
       & strInput & vbCRLF _
       & "&#60;/BODY&#62;<BR>" & vbCRLF _
       & "&#60;/HTML&#62;<BR><BR><BR>" & vbCRLF _
       & "<INPUT TYPE=" & Chr(34) & "BUTTON" & Chr(34) & "NAME=" & Chr(34) & "Test" & Chr(34) & " VALUE=" & Chr(34) & "Test" & Chr(34) & "BORDER=0>" & vbCRLF _
       & "<INPUT TYPE=" & Chr(34) & "BUTTON" & Chr(34) & "NAME=" & Chr(34) & "Volver" & Chr(34) & " VALUE=" & Chr(34) & "Back" & Chr(34) & "BORDER=0>" & vbCRLF _
       & "<SCR" & "IPT LANGUAGE=" & Chr(34) & "VBSCRIPT" & Chr(34) & ">" & vbCRLF _
       & "<!--" & vbCRLF _
       & "Sub Test_OnClick" & vbCRLF _
       & "  MsgBox " & Chr(34) & strText & Chr(34) & ", " & Var & ", " & Chr(34) & strTitle & Chr(34) & vbCRLF _
       & "End Sub" & vbCRLF _
       & "Sub Back_OnClick" & vbCRLF _
       & "  window.history.back" & vbCRLF _
       & "End Sub" & vbCRLF _
       & "//-->" & vbCRLF _
       & "</SCR" & "IPT>" & vbCRLF _
       & "</body>" & vbCRLF _
       & "</html>"

End Function
//-->
</SCRIPT>
<FORM NAME="Box">

¿Cuándo debe ser invocado el mensaje:<BR>
<select size="1" name="Sub">
<option value="1">Cuando se pulse un botón</option>
<option value="2">Cuando se pulse una imagen</option>
<option value="3">Cuando la página esté cargándose</option>
<option value="4">Cuando la página se esté cerrando</option>
</select><BR>
<BR>
Título del mensaje:<BR>
<input type="TEXT" name="Title" value="Título" Size="20"><BR>
<BR>
Texto del mensaje:<BR>
<input type="TEXT" name="Text" value="Mensaje de texto" Size="40"><BR>
<BR>
Botones:<BR>
<select size="1" name="Buttons">
<option value="0">Sólo un boton OK</option>
<option value="1">Botones OK y Cancel</option>
<option value="2">Botones de abortar, reintentar e ignorar</option>
<option value="3">Botones, Sí, No y Cancelar</option>
<option value="4">Botones Sí y No</option>
<option value="5">Botones Cancelar y Reintentar</option>
</select><BR>
<BR>
Tipo de icono:<BR>
<select size="1" name="Icon">
<option value="0">[ninguno]</option>
<option value="16">Error</option>
<option value="32">Pregunta</option>
<option value="48">Aviso</option>
<option value="64">Información</option>
</select><BR>
<BR>
<input type="button" name="cmdCreate" Value="Crear">
</FORM>
</BODY>
</HTML>