Show navigation | Frontpage | Contact us | Sitemap

<% @Control Language="C#" %>
    <script language="C#" runat="server">
        void btnDecrease_Click(Object Src, EventArgs E)
        {
            int CurrentValue = GetCurrentValue();
            CurrentValue--;
            txtValue.Text = CurrentValue.ToString();
        }

        void btnIncrease_Click(Object Src, EventArgs E)
        {
            int CurrentValue = GetCurrentValue();
            CurrentValue++;
            txtValue.Text = CurrentValue.ToString();
        }

        int GetCurrentValue()
        {
            try
            {
                return Convert.ToInt32(txtValue.Text);
            }
            catch( Exception )
            {
                return 0; // Return 0 if txtValue.Text is not numeric
            }
        }
</script>

<form runat=server>
    <asp:Button id="btnDecrease" text="Decrease" onclick="btnDecrease_Click" runat="server"/>
    <asp:TextBox id="txtValue" runat="server" value="0" />
    <asp:Button id="btnIncrease" text="Increase" onclick="btnIncrease_Click" runat="server"/>
</form> 
   

My modules


© 2008 Composite A/S, Danmark
Tlf: +45 39 15 76 00 | info@composite.net
Composite A/S er Microsoft Certified Partner
Composite CMS overholder standarden for valid CSS
Composite CMS overholder standarden for valid XHTML 1.0
Printet fra http://www.composite.net/composite-1546.htm
Findes på denne sti: Composite Developer | 3.x technologies | ASP.NET | Embedding ASP.NET User Controls | User Control Samples | SimpleState.ascx