private void InsertData(string connectionString, string firstName, string lastname, string username, string password
int Age, string gender, string contact)
{
// define INSERT query with parameters
string query = "INSERT INTO dbo.regist (FirstName, Lastname, Username, Password, Age, Gender,Contact) " +
"VALUES (@FirstName, @Lastname, @Username, @Password, @Age, @Gender, @Contact) ";
// create connection and command
using(SqlConnection cn = new SqlConnection(connectionString))
using(SqlCommand cmd = new SqlCommand(query, cn))
{
// define parameters and their values
cmd.Parameters.Add("@FirstName", SqlDbType.VarChar, 50).Value = firstName;
cmd.Parameters.Add("@Lastname", SqlDbType.VarChar, 50).Value = lastName;
cmd.Parameters.Add("@Username", SqlDbType.VarChar, 50).Value = userName;
cmd.Parameters.Add("@Password", SqlDbType.VarChar, 50).Value = password;
cmd.Parameters.Add("@Age", SqlDbType.Int).Value = age;
cmd.Parameters.Add("@Gender", SqlDbType.VarChar, 50).Value = gender;
cmd.Parameters.Add("@Contact", SqlDbType.VarChar, 50).Value = contact;
// open connection, execute INSERT, close connection
cn.Open();
cmd.ExecuteNonQuery();
cn.Close();
}
}
Laboratorio 4 UTN
miércoles, 22 de octubre de 2014
Una forma mas correcta de insertar un registro
jueves, 7 de agosto de 2014
Guia 1 HTML
GUÍA DE EJERCICIOS PRÁCTICOS NRO. 1 - HTML
- Confeccione una página que muestre en un párrafo datos referentes a sus estudios y en otro párrafo su nombre y mail.
- Confeccionar el titular de un periódico con un título de nivel 1. Luego definir dos títulos de segundo nivel con los textos (Noticias políticas y Noticias deportivas), en cada una de estas secciones definir dos titulares de tercer nivel con un párrafo cada una. Al final de la página mostrar un título de cuarto nivel con el nombre de la empresa propietaria del periódico.
- Confeccionar una página principal con dos hipervínculos a las páginas pagina2.html y pagina3.html
Luego en las dos páginas secundarias disponer hipervínculos a la página principal - Disponer una serie de hipervínculos sobre noticias del día. Enlazar los hipervínculos con anclas que se encuentran más abajo en la misma página.
- Confeccione una lista ordenada con los tres países con mayor población del planeta. Disponer un título de segundo nivel y debajo de la lista la suma de habitantes de esos tres países enfatizados.
- Confeccionar una tabla que muestre en la primer columna los nombre de distintos empleados de una compañía y en la segunda el sueldo bruto (la compañía tiene 4 empleados) Disponer en la tabla un título representativo.
- Confeccionar una tabla que muestre los nombres de periódicos y su nombre de dominio agrupados por países. En la primer columna disponer los nombre de países, expandir en fila de acuerdo a la cantidad de diarios de cada pais.
miércoles, 4 de junio de 2014
jueves, 22 de mayo de 2014
Tutorial de divs y User control
http://learnlayout.com/position.html
ControlFecha.ascx :
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ControlFecha.ascx.cs" Inherits="WebApplication1.ControlFecha" %>
Dia<asp:TextBox runat="server" ID="txtDia"></asp:TextBox>
Mes<asp:TextBox runat="server" ID="txtMes"></asp:TextBox>
Anio<asp:TextBox runat="server" ID="txtAnio"></asp:TextBox>
-------------------------------------------------------------------------------------------------------
ControlFecha.ascx.cs :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication1
{
public partial class ControlFecha : System.Web.UI.UserControl
{
public string Dia
{
get
{
return txtDia.Text;
}
set
{
txtDia.Text = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
---------------------------------------------------------------
WebForm1
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>
<%@ Register TagPrefix="uc" TagName="CntlFecha"
Src="~/ControlFecha.ascx" %>
<!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>
<form id="form1" runat="server">
<div>
<uc:CntlFecha runat="server" Dia="01" />
</div>
</form>
</body>
</html>
User Control
ControlFecha.ascx :
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ControlFecha.ascx.cs" Inherits="WebApplication1.ControlFecha" %>
Dia<asp:TextBox runat="server" ID="txtDia"></asp:TextBox>
Mes<asp:TextBox runat="server" ID="txtMes"></asp:TextBox>
Anio<asp:TextBox runat="server" ID="txtAnio"></asp:TextBox>
-------------------------------------------------------------------------------------------------------
ControlFecha.ascx.cs :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication1
{
public partial class ControlFecha : System.Web.UI.UserControl
{
public string Dia
{
get
{
return txtDia.Text;
}
set
{
txtDia.Text = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
---------------------------------------------------------------
WebForm1
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>
<%@ Register TagPrefix="uc" TagName="CntlFecha"
Src="~/ControlFecha.ascx" %>
<!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>
<form id="form1" runat="server">
<div>
<uc:CntlFecha runat="server" Dia="01" />
</div>
</form>
</body>
</html>
miércoles, 7 de mayo de 2014
Ejemplo clase 07-05-2014
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>
<!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>
<form id="form1" runat="server">
<div>
<asp:Label runat="server" ID="lblTitulo">Titulo</asp:Label>
<asp:Repeater ID="rptPersonas" runat="server">
<ItemTemplate>
<div style="float:left">
<img src="imagen1.png" />
<span style="color: Red">
<%# Eval("nombre") == "juan" ? "XXXXX" : Eval("nombre")%>
</span>
<span style="color: Red">
<%# Eval("Apellido") %>
</span>
</div>
</ItemTemplate>
<AlternatingItemTemplate>
<div style="float:right">
<img src="imagen1.png" />
<span style="color: Red">
<%# Eval("nombre") %>
</span>
</div>
<div style="clear: both">
</div>
</AlternatingItemTemplate>
</asp:Repeater>
</div>
</form>
<script language="javascript" type="text/javascript">
window.document.getElementById('<%= lblTitulo.ClientID %>').style.color = "blue";
</script>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication1
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
List<Persona> personas = new List<Persona>();
Persona p1 = new Persona();
p1.apellido = "Perez";
p1.nombre = "juan";
personas.Add(p1);
Persona p2 = new Persona();
p2.apellido = "Gomez";
p2.nombre = "Ricardo";
personas.Add(p2);
Persona p3 = new Persona();
p3.apellido = "Carlos";
p3.nombre = "Tevez";
personas.Add(p3);
rptPersonas.DataSource = personas;
rptPersonas.DataBind();
}
}
public class Persona
{
public string nombre { get; set; }
public string apellido { get; set; }
}
}
<!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>
<form id="form1" runat="server">
<div>
<asp:Label runat="server" ID="lblTitulo">Titulo</asp:Label>
<asp:Repeater ID="rptPersonas" runat="server">
<ItemTemplate>
<div style="float:left">
<img src="imagen1.png" />
<span style="color: Red">
<%# Eval("nombre") == "juan" ? "XXXXX" : Eval("nombre")%>
</span>
<span style="color: Red">
<%# Eval("Apellido") %>
</span>
</div>
</ItemTemplate>
<AlternatingItemTemplate>
<div style="float:right">
<img src="imagen1.png" />
<span style="color: Red">
<%# Eval("nombre") %>
</span>
</div>
<div style="clear: both">
</div>
</AlternatingItemTemplate>
</asp:Repeater>
</div>
</form>
<script language="javascript" type="text/javascript">
window.document.getElementById('<%= lblTitulo.ClientID %>').style.color = "blue";
</script>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication1
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
List<Persona> personas = new List<Persona>();
Persona p1 = new Persona();
p1.apellido = "Perez";
p1.nombre = "juan";
personas.Add(p1);
Persona p2 = new Persona();
p2.apellido = "Gomez";
p2.nombre = "Ricardo";
personas.Add(p2);
Persona p3 = new Persona();
p3.apellido = "Carlos";
p3.nombre = "Tevez";
personas.Add(p3);
rptPersonas.DataSource = personas;
rptPersonas.DataBind();
}
}
public class Persona
{
public string nombre { get; set; }
public string apellido { get; set; }
}
}
jueves, 27 de marzo de 2014
Ejercicios 2014
1. Realizar una aplicación web que permita mostrar diferentes cotizaciones de monedas. El usuario
deberá ingresar un monto y seleccionar el tipo de moneda para que el sistema muestre el importe
correspondiente.
2. Realizar una aplicación web que permita registrar usuarios para un evento que se realizara en la
facultad. Los datos solicitados son:
a. Apellido y Nombre
b. Email (2 veces para evitar errores.)
c. Teléfono.
d. Carrera que estudia
e. Seleccionar como se entero del evento con las opciones: Por Mail, Pagina web de la
Facultad, otros (detallar).
deberá ingresar un monto y seleccionar el tipo de moneda para que el sistema muestre el importe
correspondiente.
2. Realizar una aplicación web que permita registrar usuarios para un evento que se realizara en la
facultad. Los datos solicitados son:
a. Apellido y Nombre
b. Email (2 veces para evitar errores.)
c. Teléfono.
d. Carrera que estudia
e. Seleccionar como se entero del evento con las opciones: Por Mail, Pagina web de la
Facultad, otros (detallar).
- Un banco desea desarrollar una pagina web que permita consultar prestamos bancarios. Se otorgan dos tipos de préstamos: Personales (Hasta $50000 – cuotas desde 12 a 60) e Hipotecarios (desde $50000 – cuotas de 60 a 240). Para el primer caso se solicita el sueldo neto y el monto del préstamo. El único requerimiento es que el sueldo neto supere los $3000. Para los hipotecarios, el sueldo mínimo es de $7000. La pagina deberá mostrar una tabla que detalle el valor de la cuota que deberá abonar, Ejemplo:
- Prestamo Personal
$ 20000.-
Cuotas
|
interes
|
Cuota
|
12
|
1.20
|
….
|
24
|
1.40
| |
…
|
….
| |
60
|
2.10
|
- La Biblioteca de la facultad desea implementar un sitio web que permita consultar los libros que allí se encuentran. En una pagina se realizara la búsqueda con opción a diferentes filtros, al seleccionar un libro se abrirá otra pagina que detalle la información. (aplicar controles de validación – themes)
martes, 29 de octubre de 2013
Ejemplo de Ajax con las librerias de microsoft
ejemplo 1
------------------------------------------------------------------
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm3.aspx.cs" Inherits="WebApplication5.WebForm3" %>
<!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>
<form id="form1" runat="server">
<div>
<asp:ScriptManager runat="server"></asp:ScriptManager>
<asp:UpdatePanel runat="server" UpdateMode="Always">
<ContentTemplate>
<fieldset>
<legend>UpdatePanel</legend>
<asp:Label ID="Label1" runat="server" Text="Panel created."></asp:Label><br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</fieldset>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
--------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication5
{
public partial class WebForm3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Button1.Click += new EventHandler(Button1_Click);
}
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "Refreshed at " +
DateTime.Now.ToString();
}
}
}
Ejemplo2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication5
{
public partial class WebForm4 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
timer1.Tick += new EventHandler<EventArgs>(timer1_Tick);
}
void timer1_Tick(object sender, EventArgs e)
{
Label1.Text = "Refreshed at " +
DateTime.Now.ToString();
}
}
}
-------------------------
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm4.aspx.cs" Inherits="WebApplication5.WebForm4" %>
<!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>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:Timer runat="server" ID="timer1" Interval="1000" ></asp:Timer>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="timer1" />
</Triggers>
<ContentTemplate>
<fieldset>
<legend>UpdatePanel</legend>
<asp:Label ID="Label1" runat="server" Text="Panel created."></asp:Label><br />
</fieldset>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
------------------------------------------------------------------
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm3.aspx.cs" Inherits="WebApplication5.WebForm3" %>
<!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>
<form id="form1" runat="server">
<div>
<asp:ScriptManager runat="server"></asp:ScriptManager>
<asp:UpdatePanel runat="server" UpdateMode="Always">
<ContentTemplate>
<fieldset>
<legend>UpdatePanel</legend>
<asp:Label ID="Label1" runat="server" Text="Panel created."></asp:Label><br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</fieldset>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
--------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication5
{
public partial class WebForm3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Button1.Click += new EventHandler(Button1_Click);
}
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "Refreshed at " +
DateTime.Now.ToString();
}
}
}
Ejemplo2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication5
{
public partial class WebForm4 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
timer1.Tick += new EventHandler<EventArgs>(timer1_Tick);
}
void timer1_Tick(object sender, EventArgs e)
{
Label1.Text = "Refreshed at " +
DateTime.Now.ToString();
}
}
}
-------------------------
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm4.aspx.cs" Inherits="WebApplication5.WebForm4" %>
<!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>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:Timer runat="server" ID="timer1" Interval="1000" ></asp:Timer>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="timer1" />
</Triggers>
<ContentTemplate>
<fieldset>
<legend>UpdatePanel</legend>
<asp:Label ID="Label1" runat="server" Text="Panel created."></asp:Label><br />
</fieldset>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
Suscribirse a:
Entradas (Atom)