Creating Counter
How can I create a counter on a webpage?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Pramod Kumar NandagiriRank #6,963 · 252 reputationPosted Feb 22, 2012, 8:29 PM EST
if my assumption is right? then below is the code
page_load
{
if(!ispostback)
{
viewstate["count"]=0;
}
}
button1_click
{
//for every post back the count will be increased by 1
viewstate["count"]=(int) viewstate["count"]+1;
// below line gives the total count of postbacks
int count=convert.toint32( viewstate["count"])
}