473,325 Members | 2,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

initial load only

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
Oct 2 '06 #1
3 2939
its ok
just found If Not Page.IsPostBack Then

Thanks for looking

--
nivekski
www.kevsbox.com
"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

Oct 2 '06 #2
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

Oct 2 '06 #3
Thanks Mark
--
nivekski
www.kevsbox.com
"Mark Fitzpatrick" <ma******@fitzme.comwrote in message
news:eb*************@TK2MSFTNGP02.phx.gbl...
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


Oct 2 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Ian Murphy | last post by:
Can anyone tell me where I can find information regarding a problem I am having with w2003 ii6 and asp.net. The first page load each morning can run to 1/2hr, which as you can imagine is not...
12
by: Ian Murphy | last post by:
Hopefully someone else has seen something similar. We are experiencing an odd problem with aspnet, iis6 and w2k3. I have written a small site which works fine during the day. Each morning however...
4
by: Keith | last post by:
Hello - this started out as a minor annoyance - and now is starting to bother me more and more - I'm hoping someone can help me. I would like to have a combobox display - NOT initially be blank...
5
by: Amit | last post by:
Hello, I have a simple search screen, with two drop-downs and a text box. There's also a GridView control that is using a SqlDataSource control to show the matching results. The SqlDataSource uses...
2
by: Rick Shaw | last post by:
Hi, I have a problem with the datagridview not refreshed when the application first appear on the screen. The datagridview display data from a table in the dataset. At the same time, I've added...
1
by: aromero78 | last post by:
I have a C# .Net 2.0 web application that I'm building. Recently I've implemented caching throughout the site and it seems to work, most page loads are significantly faster, except when coming the...
0
by: David Jackson | last post by:
Hello, I first posted this several weeks ago but didn't get any replies so I'm trying again in the hope that someone might be able to help. We are in the process of upgrading our internal web...
1
by: Med | last post by:
Hi, Initial load of my ASP.NET app takes 50 seconds to load. Then it become fairly fast. Followings are my app/hardware configs: Server/IIS: ----------- IIS 6 running on Hosted VPS...
5
by: Med | last post by:
Hi, Initial load of my pre-compiled ASP.NET app takes more than 50 seconds to load after site has been idle for a while. Then it become fairly fast. Followings are my app/hardware configs: ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.