What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 5561 |  Welcome, Guest!   Register  Login
 Home > Forums > C# > How to count button clik event ...
Nareyugam

How to count button clik event

Replies: 12 | Posted by: Nareyugam on 7/24/2012 | Category: C# Forums | Views: 2222 | Status: [Member] | Points: 10  


HI all

Is there any two count no of clicks of a button control in C# and Asp.net!


Thanks in Advance

VenkatNaresh


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

 Replies

Ranjeet_8
Ranjeet_8  
Posted on: 7/24/2012 7:33:00 AM
Level: Gold | Status: [Member] | Points: 50

Resolved


    static int count = 0;  


protected void Button1_Click(object sender, EventArgs e)
{
count++;
Button1.Text=count.ToString();
}

Nareyugam, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Vuyiswamb
Vuyiswamb  
Posted on: 7/24/2012 8:18:20 AM
Level: NotApplicable | Status: [Member] [MVP] [Administrator] | Points: 25

Good Answer @Ranjeet_8

Thank you for posting at Dotnetfunda
[Administrator]

Nareyugam, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Oswaldlily
Oswaldlily  
Posted on: 7/24/2012 8:18:37 AM
Level: Starter | Status: [Member] | Points: 50

Resolved

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Label1.Text = "Label1" Then
Label1.Text = String.Empty

End If
If Label1.Text = String.Empty Then
Label1.Text = 1
Else
Label1.Text = Convert.ToString(Convert.ToInt32(Label1.Text) + 1)

End If
End Sub

Nareyugam, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Nareyugam
Nareyugam  
Posted on: 7/24/2012 1:12:15 PM
Level: Starter | Status: [Member] | Points: 25

Thanks ranjeet, i alrdy use this, need some other way..

VenkatNaresh

Nareyugam, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Patel28rajendra
Patel28rajendra  
Posted on: 7/25/2012 12:50:58 AM
Level: Starter | Status: [Member] | Points: 50

Resolved

Hi

you can store it in View state

R D Patel

Nareyugam, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Ranjeet_8
Ranjeet_8  
Posted on: 7/25/2012 1:27:40 AM
Level: Gold | Status: [Member] | Points: 50

Resolved

    protected void Page_Load(object sender, EventArgs e)

{
if (!IsPostBack)
ViewState["Count"] = 0;
}
protected void Button1_Click(object sender, EventArgs e)
{
ViewState["count"] = Convert.ToInt32(ViewState["count"]) + 1;
Button1.Text = ViewState["count"].ToString();
}

Nareyugam, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Patel28rajendra
Patel28rajendra  
Posted on: 7/25/2012 2:06:26 AM
Level: Starter | Status: [Member] | Points: 25

Hi
To do it Using Java script
refer this link
http://stackoverflow.com/questions/5736860/incrementing-the-count-on-click-of-button

R D Patel

Nareyugam, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Patel28rajendra
Patel28rajendra  
Posted on: 7/25/2012 2:10:54 AM
Level: Starter | Status: [Member] | Points: 25

Nareyugam, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Ranjeet_8
Ranjeet_8  
Posted on: 7/25/2012 2:47:29 AM
Level: Gold | Status: [Member] | Points: 25

Nareyugam, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Nareyugam
Nareyugam  
Posted on: 7/25/2012 5:16:02 AM
Level: Starter | Status: [Member] | Points: 25

Again Thanku

VenkatNaresh

Nareyugam, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Ranjeet_8
Ranjeet_8  
Posted on: 7/25/2012 6:24:22 AM
Level: Gold | Status: [Member] | Points: 25

Hi Nareyugam
Mark As Answer if my post helped u.

Nareyugam, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Nareyugam
Nareyugam  
Posted on: 7/29/2012 9:08:07 AM
Level: Starter | Status: [Member] | Points: 25

Thank you it really helpful

VenkatNaresh

Nareyugam, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Reply - Please login to reply


Click here to login & reply

Found interesting? Add this to:


 Latest Posts

Write New Post | More ...

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/24/2013 7:40:29 PM