==> [FrmLabelTextBoxButton.aspx] 소스 및 디자인

  

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FrmLabelTextBoxButton.aspx.cs" Inherits="FrmLabelTextBoxButton" %>

 

<!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 ID="lblBirth" runat="server" Text="생년월일(1982) : "></asp:Label>

        <asp:TextBox ID="txtBirth" runat="server"></asp:TextBox>

        <asp:Button ID="btnClick" runat="server" Text="클릭" onclick="btnClick_Click" />

        <br />

        <asp:Label ID="lblAge" runat="server"></asp:Label>

    </div>   

    </form>

</body>

</html>

 

 

 


 

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

 


==> [FrmLabelTextBoxButton.aspx.cs] 소스

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

 

public partial class FrmLabelTextBoxButton : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

 

    }

 

    protected void btnClick_Click(object sender, EventArgs e)

    {

        // 나이값을 구하고, 레이블에 출력

        int age = DateTime.Now.Year - Convert.ToInt32(txtBirth.Text) + 1;

        lblAge.Text = age.ToString();

    }

}

 

  

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

 


[실행결과]






Posted by holland14
: