Blog Content

    티스토리 뷰

    18.C# ASP.NET - Button 컨트롤 [WebStandardControl]

    반응형
    Button 컨트롤에 관련된 예제입니다.

    FrmButton.aspx

    <div>

     

       <asp:TextBox ID="txtNum" runat="server" Text="0"></asp:TextBox>

      

       <asp:Button ID="btnUp" runat="server" Text="증가"

           onclick="btnUp_Click" />

      

       <asp:Button ID="btnDown" runat="server" Text="감소"

           onclick="btnDown_Click" />

     

    </div>


    FrmButton.aspx.cs

    protected void btnUp_Click(object sender, EventArgs e)

    {

       txtNum.Text = Convert.ToString(Convert.ToInt32(txtNum.Text) + 1);   

    }

     

    protected void btnDown_Click(object sender, EventArgs e)

    {

       txtNum.Text = Convert.ToString(Int32.Parse(txtNum.Text) - 1);   

    }


    결과화면

    [그림18-1]



    반응형

    Comments