Click here to Skip to main content
15,889,595 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends,

I need code for...,

In a Asp.net page, there is one Update panel. In that Update Panel, there is One Lable and Button. Lable is filled with a number for example 10.My requirement is, when ever i click the button, in the lable text 10 will be decreased to 10,9..........2,1,0 finally stop the number.
advance thankyou for sending code....
Posted

You will not be receiving code from us because that is not how it works here.
Try writing some code, see how far you get, and then ask more specific coding based questions. We will be very happy to help. This is a very simple assignment. All you need is an asp.net project, a web form with a text box and a label in an update panel. Handle the button click and process it in your code behind. Go forth and code, my good fellow.
 
Share this answer
 
Comments
thatraja 25-May-11 11:13am    
Agree, 5!
You can use timer to decrease the numbers
You can set the code like this

Button1_Click
VB
Timer1.Enabled = True



Timer1_tick
VB
If lbl1.text >=0 Then
     lbl1.text = CInt(lbl1.text) - 1
Else
     Timer1.Enabled = False
End If
 
Share this answer
 
Here is the ans for your Q
C#
protected void Lable_Click(object sender, EventArgs e)
    {

                   (Label)sender).Text=  (Convert.ToInt32(((Label)sender).Text)==0?0:Convert.ToInt32(((Label)sender).Text)-1).toString();
}
 
Share this answer
 
You can do this like

protected void btn_click(object sender, EventArgs e)
{
  int num = 0;
  int.TryParse(lbl.text,out num)
  if(num > 0)
  {
    lbl.text = num -1;
  }

}
 
Share this answer
 
Comments
beginner in C#.net 25-May-11 9:58am    
its not working...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900