Está en la página 1de 16

Introducción a la programación

Tarea sesión 4

Alumno: Victor Daniel Rascon Marquez


Profesor: Ing. Elizabeth Mayela Sánchez Salinas
Carrera: Ingeniería petrolera y energías renovables
3er Grado
Índice
Interfaz multipágina con manejo avanzado de cuadros de texto, barra de menús y botones de
comando .................................................................................................................................................. 1
Codigo ................................................................................................................................................. 6
Ejecución............................................................................................................................................. 7
Creación de una página Web ASP.NET, prueba e identificación de sus elementos ............................. 9
Codigo ................................................................................................................................................ 10
Ejecución............................................................................................................................................ 13
Identificación de elementos .............................................................................................................. 14
Interfaz multipágina con manejo avanzado de cuadros de texto,
barra de menús y botones de comando

1
2
3
4
5
Codigo

Public Class frmEmpresa


Sub LimpiaCampos()
' Campos del primer TabPage
mtbIDEmpresa.Text = ""
txtNombre.Text = ""
txtDireccion.Text = ""
txtNIP.Text = ""

' Campos del segundo TabPage


txtNombreCon.Text = ""
mtbTelefono.Text = ""
rbtnMasculino.Checked = True
cboTitulo.SelectedIndex = 0

' Campos del tercer TabPage


chkSitio.Checked = False
txtURL.Text = ""
txtURL.Enabled = False
btnVerSitio.Enabled = False
End Sub

Private Sub LimpiarCamposToolStripMenuItem_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
LimpiarCamposToolStripMenuItem.Click
Call LimpiaCampos()
End Sub

Private Sub CerrarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal


e As System.EventArgs) Handles CerrarToolStripMenuItem.Click
Me.Close()
End Sub

Private Sub frmEmpresa_Load(


ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call LimpiaCampos()
End Sub
Sub ActivaAceptar(ByVal sender As Object, ByVal e As EventArgs) Handles
mtbIDEmpresa.LostFocus, txtNombre.LostFocus, txtDireccion.LostFocus,
txtNIP.LostFocus, txtNombreCon.LostFocus, mtbTelefono.LostFocus
If mtbIDEmpresa.Text = "" Or txtNombre.Text = "" _
Or txtDireccion.Text = "" Or txtNIP.Text = "" _
Or txtNombreCon.Text = "" Or mtbTelefono.Text = "" Then
btnAceptar.Enabled = False
Else
btnAceptar.Enabled = True
End If
End Sub

6
Private Sub chkSitio_CheckedChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles chkSitio.CheckedChanged
txtURL.Enabled = chkSitio.Checked
btnVerSitio.Enabled = chkSitio.Checked
End Sub

Private Sub btnVerSitio_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnVerSitio.Click
webPagina.Navigate(New Uri(txtURL.Text))
End Sub
End Class

Ejecución

7
8
Creación de una página Web ASP.NET, prueba e identificación de
sus elementos

9
Codigo
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Usuario.aspx.vb"
Inherits="Usuario" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body style="height: 350px">
<form id="form1" runat="server">
<div>

<asp:Label ID="Label2" runat="server"


style="z-index: 1; left: 14px; top: 70px; position: absolute"
Text="Correo: "></asp:Label>
<asp:Label ID="Label3" runat="server"
style="z-index: 1; left: 15px; top: 104px; position: absolute"
Text="Edad:"></asp:Label>

</div>
<asp:Label ID="Label1" runat="server"
style="z-index: 1; left: 14px; top: 40px; position: absolute"
Text="Nombre:"></asp:Label>
<asp:TextBox ID="txtNombre" runat="server" MaxLength="40"
style="z-index: 1; left: 65px; top: 36px; position: absolute; width:
278px"
ToolTip="Capture aquí su nombre"></asp:TextBox>
<p>
<asp:TextBox ID="txtCorreo" runat="server" MaxLength="40"

10
style="z-index: 1; left: 62px; top: 65px; position: absolute; width:
279px"
ToolTip="Capture aquí su correo electrónico"></asp:TextBox>
</p>
<p>
<asp:Label ID="Label4" runat="server"
style="z-index: 1; left: 14px; top: 135px; position: absolute"
Text="Inicio:"></asp:Label>
<asp:TextBox ID="txtEdad" runat="server" MaxLength="3"
style="z-index: 1; left: 60px; top: 103px; position: absolute; width:
57px"
ToolTip="Capture su edad (0 a 100)"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
runat="server"
ControlToValidate="txtCorreo" Display="Dynamic"
ErrorMessage="Formato de correo electrónico incorrecto."
style="z-index: 1; left: 407px; top: 64px; position: absolute; width:
8px"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-
.]\w+)*">*</asp:RegularExpressionValidator>
</p>
<p>
<asp:TextBox ID="txtInicio" runat="server"
style="z-index: 1; left: 59px; top: 134px; position: absolute; width:
276px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txtNombre" Display="Dynamic"
ErrorMessage=" El nombre no debe omitirse"
style="z-index: 1; left: 364px; top: 37px; position: absolute; bottom:
249px">*</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="txtCorreo" Display="Dynamic"
ErrorMessage="El correo no puede omitirse"
style="z-index: 1; left: 362px; top: 64px; position: absolute; width:
13px; right: 546px">*</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="txtEdad" Display="Dynamic"
ErrorMessage="La edad no puede omitirse"
style="z-index: 1; left: 139px; top: 98px; position:
absolute">*</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="txtInicio" Display="Dynamic"
ErrorMessage="La fecha de inicio de servicios no debe omitirse"
style="z-index: 1; left: 359px; top: 129px; position: absolute;
height: 20px">*</asp:RequiredFieldValidator>
</p>
<asp:RangeValidator ID="RangeValidator1" runat="server"
ControlToValidate="txtEdad" Display="Dynamic"
ErrorMessage="La edad no está dentro del rango permitido"
MaximumValue="100"
MinimumValue="0"
style="z-index: 1; left: 185px; top: 98px; position: absolute; right:
728px"
Type="Integer">*</asp:RangeValidator>

11
<asp:CompareValidator ID="CompareValidator1" runat="server"
ControlToValidate="txtEdad" Display="Dynamic"
ErrorMessage="La edad debe ser un número entero" Operator="DataTypeCheck"
style="z-index: 1; left: 227px; top: 97px; position:
absolute">*</asp:CompareValidator>
<asp:Calendar ID="calInicio" runat="server"
style="z-index: 1; left: 100px; top: 170px; position: absolute; height:
188px; width: 259px">
</asp:Calendar>
<asp:CustomValidator ID="CustomValidator1" runat="server"
ControlToValidate="txtInicio" Display="Dynamic"
ErrorMessage="La fecha de inicio de uso es incorrecta"
style="z-index: 1; left: 386px; top: 127px; position:
absolute">*</asp:CustomValidator>
<asp:Button ID="btnAceptar" runat="server"
style="z-index: 1; left: 102px; top: 367px; position: absolute"
Text="Aceptar datos" />
<hr style="z-index: 1; left: 13px; top: 391px; position: absolute; height:
16px; width: 901px" />
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="http://www.aprendapracticando.com"
style="z-index: 1; left: 23px; top: 434px; position: absolute">Ir al sitio
de Aprenda Practicando</asp:HyperLink>
<asp:ValidationSummary ID="ValidationSummary1" runat="server"
ShowMessageBox="True" ShowSummary="False"
style="z-index: 1; left: 4px; top: 480px; position: absolute; height:
38px; width: 901px" />
</form>
</body>
</html>

12
Ejecución

13
Identificación de elementos

Cuadro de texto (TextBox) con


validadores de campo requerido
Etiqueta (Label) (RequiredFieldValidator

Validador de expresión regular


(RegularExpressionValidator)
Validador de rango (RangeValidator)
Validador personalizado (CustomValidator)
Validador de comparación (CompareValidator)

Calendario (Calendar)

Botón de comando (Button)

Hipervínculo (HyperLink).

14

También podría gustarte