Sie sind auf Seite 1von 9

Ejercicios resueltos Controles Web

Pregunta 1: Confeccionar una página que solicite el ingreso del nombre y apellido de
una persona (cada elemento en un TextBox), luego al presionar un botón mostrar en una
label si alguno de los datos no se cargó.

Protected Sub BtnMostrar_Click(sender As Object, e As EventArgs) Handles


BtnMostrar.Click
lblr.Text = ""
If txtnom.Text = "" And txtape.Text = "" Then
lblr.Text = "Falta ingresar Nombres & Apellidos"
ElseIf txtnom.Text = "" Then
lblr.Text = "Falta ingresar Nombres"
ElseIf txtape.Text = "" Then
lblr.Text = "Falta ingresar Apellidos"
End If
End Sub
Pregunta2: Confeccionar una página que muestre un examen múltiple choice (disponer
4 preguntas y tres respuestas posibles por pregunta) utilizar controles de tipo
RadioButton para la selección de la respuesta correcta.
Mostrar la cantidad de respuestas correctas luego que se presiona un botón.

Protected Sub btnver_Click(sender As Object, e As EventArgs) Handles btnver.Click


lblr.Text = ""
If RadioButtonList1.Text = 20 And RadioButtonList2.Text = 400 And
RadioButtonList3.Text = 1 And RadioButtonList4.Text = 30 Then
lblr.Text = "Respuestas Correctas"
ElseIf RadioButtonList1.Text = 20 And RadioButtonList2.Text = 400 And
RadioButtonList3.Text = 1 And RadioButtonList4.Text <> 30 Then
lblr.Text = "Pregunta1: Correcta" & "<br/>" & "Pregunta2: Correcta" & "<br/>"
& "Pregunta3: Correcta" & "<br/>" & "Pregunta4: Incorrecta"
ElseIf RadioButtonList1.Text = 20 And RadioButtonList2.Text = 400 And
RadioButtonList3.Text <> 1 And RadioButtonList4.Text = 30 Then
lblr.Text = "Pregunta1: Correcta" & "<br/>" & "Pregunta2: Correcta" & "<br/>"
& "Pregunta3: Incorrecta" & "<br/>" & "Pregunta4: Correcta"
ElseIf RadioButtonList1.Text = 20 And RadioButtonList2.Text <> 400 And
RadioButtonList3.Text = 1 And RadioButtonList4.Text = 30 Then
lblr.Text = "Pregunta1: Correcta" & "<br/>" & "Pregunta2: Incorrecta" &
"<br/>" & "Pregunta3: Correcta" & "<br/>" & "Pregunta4: Correcta"
ElseIf RadioButtonList1.Text <> 20 And RadioButtonList2.Text = 400 And
RadioButtonList3.Text = 1 And RadioButtonList4.Text = 30 Then
lblr.Text = "Pregunta1: Incorrecta" & "<br/>" & "Pregunta2: Correcta" &
"<br/>" & "Pregunta3: Correcta" & "<br/>" & "Pregunta4: Correcta"
ElseIf RadioButtonList1.Text = 20 And RadioButtonList2.Text = 400 And
RadioButtonList3.Text <> 1 And RadioButtonList4.Text <> 30 Then
lblr.Text = "Pregunta1: Correcta" & "<br/>" & "Pregunta2: Correcta" & "<br/>"
& "Pregunta3: Incorrecta" & "<br/>" & "Pregunta4: Incorrecta"
ElseIf RadioButtonList1.Text = 20 And RadioButtonList2.Text <> 400 And
RadioButtonList3.Text <> 1 And RadioButtonList4.Text = 30 Then
lblr.Text = "Pregunta1: Correcta" & "<br/>" & "Pregunta2: Incorrecta" &
"<br/>" & "Pregunta3: Incorrecta" & "<br/>" & "Pregunta4: Correcta"
ElseIf RadioButtonList1.Text <> 20 And RadioButtonList2.Text <> 400 And
RadioButtonList3.Text = 1 And RadioButtonList4.Text = 30 Then
lblr.Text = "Pregunta1: Incorrecta" & "<br/>" & "Pregunta2: Incorrecta" &
"<br/>" & "Pregunta3: Correcta" & "<br/>" & "Pregunta4: Correcta"
ElseIf RadioButtonList1.Text = 20 And RadioButtonList2.Text <> 400 And
RadioButtonList3.Text = 1 And RadioButtonList4.Text <> 30 Then
lblr.Text = "Pregunta1: Correcta" & "<br/>" & "Pregunta2: Incorrecta" &
"<br/>" & "Pregunta3: Correcta" & "<br/>" & "Pregunta4: Incorrecta"
ElseIf RadioButtonList1.Text <> 20 And RadioButtonList2.Text = 400 And
RadioButtonList3.Text <> 1 And RadioButtonList4.Text = 30 Then
lblr.Text = "Pregunta1: Incorrecta" & "<br/>" & "Pregunta2: Correcta" &
"<br/>" & "Pregunta3: Incorrecta" & "<br/>" & "Pregunta4: Correcta"
ElseIf RadioButtonList1.Text = 20 And RadioButtonList2.Text <> 400 And
RadioButtonList3.Text <> 1 And RadioButtonList4.Text <> 30 Then
lblr.Text = "Pregunta1: Correcta" & "<br/>" & "Pregunta2: Incorrecta" &
"<br/>" & "Pregunta3: Incorrecta" & "<br/>" & "Pregunta4: Incorrecta"
ElseIf RadioButtonList1.Text <> 20 And RadioButtonList2.Text = 400 And
RadioButtonList3.Text <> 1 And RadioButtonList4.Text <> 30 Then
lblr.Text = "Pregunta1: Incorrecta" & "<br/>" & "Pregunta2: Correcta" &
"<br/>" & "Pregunta3: Incorrecta" & "<br/>" & "Pregunta4: Incorrecta"
ElseIf RadioButtonList1.Text <> 20 And RadioButtonList2.Text <> 400 And
RadioButtonList3.Text = 1 And RadioButtonList4.Text <> 30 Then
lblr.Text = "Pregunta1: Incorrecta" & "<br/>" & "Pregunta2: Incorrecta" &
"<br/>" & "Pregunta3: Correcta" & "<br/>" & "Pregunta4: Incorrecta"
ElseIf RadioButtonList1.Text <> 20 And RadioButtonList2.Text <> 400 And
RadioButtonList3.Text <> 1 And RadioButtonList4.Text = 30 Then
lblr.Text = "Pregunta1: Incorrecta" & "<br/>" & "Pregunta2: Incorrecta" &
"<br/>" & "Pregunta3: Incorrecta" & "<br/>" & "Pregunta4: Correcta"
ElseIf RadioButtonList1.Text <> 20 And RadioButtonList2.Text <> 400 And
RadioButtonList3.Text <> 1 And RadioButtonList4.Text <> 30 Then
lblr.Text = "Pregunta1: Incorrecta" & "<br/>" & "Pregunta2: Incorrecta" &
"<br/>" & "Pregunta3: Incorrecta" & "<br/>" & "Pregunta4: Incorrecta"
End If
End Sub
Pregunta 3: Solicitar el ingreso de un número en un textbox. Verificar con la función
IsNumeric si se trata de un número. En caso que se trate de un número mostrar la
cantidad de dígitos que tiene.
Protected Sub btnMostrar_Click(sender As Object, e As EventArgs) Handles
btnMostrar.Click
If IsNumeric(txtn.Text) Then
MsgBox("Es un numero", MsgBoxStyle.Information)
lblr.Text = "La cantidad de digitos es: " & Len(txtn.Text)
Else
MsgBox("No es un numero", MsgBoxStyle.Information)
End If
End Sub
Pregunta 4: Disponer un conjunto de RadioButton agrupados. Mostrar en las leyendas
de cada RadioButton distintos buscadores (Google, Bing, Yahoo etc.)
Cuando se presione un botón redireccionar a dicho servidor (para redireccionar
debemos utilizar la siguiente sintaxis response.redirect(http://www.google.com)

Protected Sub RadioButtonList1_SelectedIndexChanged(sender As Object, e As


EventArgs) Handles RadioButtonList1.SelectedIndexChanged
If RadioButtonList1.Text = "Google" Then
Response.Redirect("http://www.google.com")
ElseIf RadioButtonList1.Text = "Bing" Then
Response.Redirect("http://www.bing.com")
ElseIf RadioButtonList1.Text = "Yahoo" Then
Response.Redirect("http://www.yahoo.com")
End If
End Sub
Pregunta 5: Confeccionar el siguiente formulario para registrarse en un sitio web
(utilizar controles de la pestaña estándar)
En una Label mostrar los datos cargados en cada control (disponer la Label al final del
formulario).
Protected Sub btnAceptar_Click(sender As Object, e As EventArgs) Handles
btnAceptar.Click
lblr.Text = ""
Dim r As String
If RadioButtonList1.Text = "Masculino" Then
r = "Mascullino"
ElseIf RadioButtonList1.Text = "Femenino" Then
r = "Femenino"
End If
lblr.Text = "Nombre Usuario: " & txtusu.Text & "<br/>" & "Clave: " &
txtclave.Text & "<br/>" & _
"Repita Clave: " & txtrclave.Text & "<br/>" & "Correo electronico: " &
txtemail.Text & "<br/>" & _
"Apellidos: " & txtape.Text & "<br/>" & "Nombres: " & txtnom.Text &
"<br/>" & "Pais origen: " & DropDownList1.Text & "<br/>" & _
"Provincia: " & txtpro.Text & "<br/>" & "Codigo Postal: " & txtpos.Text &
"<br/>" & "Sexo: " & r & "<br/>" & _
"Fecha Nacimiento: " & txtfe.Text & "<br/>" & "Comentarios: " &
txtco.Text
End Sub

Das könnte Ihnen auch gefallen