Hi tareq16278,
please refer below sample.
HTML
<asp:Button ID="btnMinus" runat="server" OnClick="OnMinus"
Style="font-weight: 700; font-size: x-large" Text="-" />
<asp:TextBox ID="txtNumber" runat="server" Width="49px"></asp:TextBox>
<asp:Button ID="btnPlus" runat="server" OnClick="OnPlus"
Style="font-size: x-large" Text="+" />
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
txtNumber.Text = "1";
}
}
protected void OnMinus(object sender, EventArgs e)
{
if (int.Parse(txtNumber.Text) > 0)
{
txtNumber.Text = (int.Parse(txtNumber.Text) - 1).ToString();
}
}
protected void OnPlus(object sender, EventArgs e)
{
txtNumber.Text = (int.Parse(txtNumber.Text) + 1).ToString();
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not IsPostBack Then
txtNumber.Text = "1"
End If
End Sub
Protected Sub OnMinus(ByVal sender As Object, ByVal e As EventArgs)
If Integer.Parse(txtNumber.Text) > 0 Then
txtNumber.Text = (Integer.Parse(txtNumber.Text) - 1).ToString()
End If
End Sub
Protected Sub OnPlus(ByVal sender As Object, ByVal e As EventArgs)
txtNumber.Text = (Integer.Parse(txtNumber.Text) + 1).ToString()
End Sub
Screenshot