The events will still be called because that is part of the normal ASP.Net
process. What you'll have to do is right before your code, determine if the
page is posting back or not. Put your code that you don't want to repeatedly
fire in a conditional statement and check to see if the Page.IsPostBack
property is true. If so then the page is reloading from a postback and
shouldn't do the code you entered.
Now, this method only handles postbacks. The page doesn't really know if
it's being refreshed unless that refresh posts data back to the server. The
best way to overcome this could be with caching instead. Caching will mean
that the page loads, then keeps itself in memory until some condition is met
to make it fall out of memory or reload (such as placing a timeout or set it
to vary the cache by some parameter). Caching may be what you are looking
for as it has the highest performance.
You'll have to toy with both of these methods to get them just right when
using a control such as a treeview.
--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006
"Starbuck" <st******@tisconi.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
Hi
I want to set a value on the initial load of a asp page and only then.
What I have noticed is that every time I click on my Treeview control all
of the following are called -
Protected Sub Page_Init(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Init
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.PreInit
Protected Sub Page_PreLoad(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.PreLoad
Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.PreRender
So my question is where do I put code that will be fired when the page is
loaded but not every time it is refreshed?
Thanks in advance
--
nivekski
www.kevsbox.com