miércoles, 4 de junio de 2014

Ejemplo de Repeaters anidados

Ejemplo de Repeaters anidados

jueves, 22 de mayo de 2014

Tutorial de divs y User control

http://learnlayout.com/position.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; }
    }
}

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).




  1. 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:


    1. Prestamo Personal
$ 20000.-


Cuotas
interes
Cuota
12
1.20
….
24
1.40

….

60
2.10





  1. 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>

jueves, 17 de octubre de 2013

Ejemplo de Base de datos

static public class AccesoDatos
    {
        static string ConnectionString = "Data Source=LAB4-SERVER;Initial Catalog=Crocitto;User ID=crocitto";
        //static string ConnectionString = "DATA SOURCE=.; INITIAL CATALOG=CARRITO; USER ID = sa; PASSWORD=andres";
        static public SqlConnection cn = new SqlConnection(ConnectionString);

        static public void Conectar()
        {
            if (cn.State == ConnectionState.Closed)
                cn.Open();
        }

        static public void Desconectar()
        {
            if (cn.State == ConnectionState.Open)
                cn.Close();
        }

    }

--------------------------------------------------------------------------------------

public class BDCategorias:Categorias
    {
        private static BDCategorias instance;
        DataTable DTCategorias = new DataTable();
        ArrayList listacategorias = new ArrayList();

        protected BDCategorias()
        {
        }

        public static BDCategorias Instance()
        {
            if (instance == null)
            {
                instance = new BDCategorias();
            }
            return instance;
        }
   
        override public void CargarCategorias()
        {
            SqlCommand cmd = new SqlCommand("select * from Categorias",AccesoDatos.cn);
            SqlDataReader reader;
            AccesoDatos.Conectar();
            reader = cmd.ExecuteReader();
            DTCategorias.Load(reader);
            AccesoDatos.Desconectar();
            DataColumn[] pk = new DataColumn[1];
            pk[0] = DTCategorias.Columns[0];
        }

        override public void Agregar(CATEGORIAS cat)
        {
            SqlCommand cmd = new SqlCommand("insert into Categorias (categoria) values ('" + cat.Nombre + "')", AccesoDatos.cn);
            AccesoDatos.Conectar();
            cmd.ExecuteNonQuery();
            AccesoDatos.Desconectar();           
        }

        override public void Eliminar(int idcateg)
        {
            SqlCommand cmd = new SqlCommand("delete from Categorias where id=" + idcateg, AccesoDatos.cn);
            AccesoDatos.Conectar();
            cmd.ExecuteNonQuery();
            AccesoDatos.Desconectar();
        }

        override public void Modificar(CATEGORIAS cat)
        {
            SqlCommand cmd = new SqlCommand("update Categorias set categoria='" + cat.Nombre + "' where id=" + cat.Id, AccesoDatos.cn);
            AccesoDatos.Conectar();
            cmd.ExecuteNonQuery();
            AccesoDatos.Desconectar();
        }

        override public CATEGORIAS Buscar(int idcat)
        {
            SqlCommand cmd = new SqlCommand("select * from Categorias where id=" + idcat, AccesoDatos.cn);
            SqlDataReader reader;
            AccesoDatos.Conectar();
            reader = cmd.ExecuteReader();
            DataTable dt1 = new DataTable();
            dt1.Load(reader);
            AccesoDatos.Desconectar();
            foreach (DataRow dt in dt1.Rows)
            {
                CATEGORIAS c = new CATEGORIAS();
                c.Id = Convert.ToInt16(dt["id"]);
                c.Nombre = dt["categoria"].ToString();
                return c;
            }
            return null;
        }
}