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
Pankaj Kumar ChoudharyPosted Jun 4, 2015, 11:22 AM
Upendra Pratap ShahiPosted Jun 4, 2015, 8:55 AM
Rajeesh MenothPosted Jun 4, 2015, 8:39 AM
ehsan soltaniPosted Jun 4, 2015, 8:36 AM
ehsan soltaniPosted Jun 4, 2015, 8:34 AM
Rajeesh MenothPosted Jun 4, 2015, 8:29 AM
ehsan soltaniPosted Jun 4, 2015, 8:27 AM
Manoj BhoirPosted Jun 4, 2015, 8:27 AM
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;
}
}
Dipankar BiswasPosted Jun 4, 2015, 8:24 AM
Rajeesh MenothPosted Jun 4, 2015, 8:23 AM
ehsan soltaniPosted Jun 4, 2015, 8:20 AM
Manoj BhoirPosted Jun 4, 2015, 8:17 AM
// 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);