Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
I have a function performing some task, i want to use this function after two times Page.Ispostback .....what code should i write...???
 

plz help............
Posted 1-Apr-13 22:29pm
Comments
Vin.k.S at 2-Apr-13 8:29am
   
You want the Hitcount or the Pageload Count ?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Store a variable in the Session, and increment it on each postback. Zero it on Page Load when not a postback.
MSDN: Session[^]
  Permalink  
Comments
akrati shakya at 2-Apr-13 3:38am
   
Sir plz can you explain me in more brief or plz write the code...
OriginalGriff at 2-Apr-13 3:43am
   
How difficult do you think this is?
Did you read the link? It includes code fragments!
You already know how to test IsPostback, so why is this difficult for you?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Use Session and maintian a variale
 

Page_Load()
{
 
if(Ispostback)
{
// second time
if(session["PageLoadCount"] !=null && Convert.ToInt32(session["PageLoadCount"])<=2)
{
session["PageLoadCount"] = Conver.ToInt32(session["PageLoadCount"])+1;
}
else
{
// do whatever do u want.
}
}
else
{
// First time page request
session["PageLoadCount"] = 1
}
 

}
  Permalink  
v2
Comments
akrati shakya at 2-Apr-13 4:01am
   
thanks you...
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Its good, one more SHAKYA is here.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 690
1 Maciej Los 280
2 Suvendu Shekhar Giri 229
3 Richard Deeming 195
4 Sascha Lefévre 164
0 Sergey Alexandrovich Kryukov 9,678
1 OriginalGriff 9,135
2 Peter Leow 5,082
3 Kornfeld Eliyahu Peter 3,373
4 Maciej Los 2,606


Advertise | Privacy | Mobile
Web01 | 2.8.150327.1 | Last Updated 5 Jul 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100