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 230
1 PIEBALDconsult 150
2 DamithSL 125
3 BillWoodruff 108
4 Garth J Lancaster 90
0 OriginalGriff 5,790
1 DamithSL 4,601
2 Maciej Los 4,012
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,195


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 5 Jul 2013
Copyright © CodeProject, 1999-2014
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