I have a problem to know the numbers of clicks on a buttons.
this is my program but It is not true;
int c=0;
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = c.ToString();
c = c + 1;
}
after clicking on button, c will be 1 and it does not change anymore.
best regards

Rajeesh MenothRank #118 · 18.4K reputationPosted Jun 4, 2015, 4:23 AM EDT
Manoj BhoirRank #599 · 4K reputationPosted Jun 4, 2015, 4:27 AM EDT
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
int c = 0;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ViewState["CountValue"] = 0;
}
else
{
}
}
protected void Button1_Click(object sender, EventArgs e)
{
c = Convert.ToInt32(ViewState["CountValue"].ToString());
Label1.Text = c.ToString();
c = c + 1;
ViewState["CountValue"] = c;
}
}
Rajeesh MenothRank #118 · 18.4K reputationPosted Jun 4, 2015, 4:39 AM EDT
Upendra Pratap ShahiRank #329 · 7.5K reputationPosted Jun 4, 2015, 4:55 AM EDT
Pankaj Kumar ChoudharyRank #80 · 24.4K reputationPosted Jun 4, 2015, 7:22 AM EDT
Manoj BhoirRank #599 · 4K reputationPosted Jun 4, 2015, 4:17 AM EDT
// button1
//
this.button1.Location = new System.Drawing.Point(101, 77);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
ehsan soltani17 reputationPosted Jun 4, 2015, 4:20 AM EDT
Dipankar BiswasRank #992 · 2K reputationPosted Jun 4, 2015, 4:24 AM EDT
ehsan soltani17 reputationPosted Jun 4, 2015, 4:27 AM EDT
Rajeesh MenothRank #118 · 18.4K reputationPosted Jun 4, 2015, 4:29 AM EDT
ehsan soltani17 reputationPosted Jun 4, 2015, 4:34 AM EDT
ehsan soltani17 reputationPosted Jun 4, 2015, 4:36 AM EDT