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; }
    }
}