473,509 Members | 2,918 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Page_Load or page top code

Can someone tell me if the code in the Page_Load sub runs every time...even
on PostBack? If so, what is the difference between the Page_Load and the <%
%code at the top of an aspx page? Thanks.

David
Oct 5 '07 #1
3 1306
page load runs every time assuming nothing is broken.

separating code from the ASP/HTML presentation is considered better
organization, which is why you should use your code behind file.

I don't know how the code at the top of the page works in relation to
the event structure to be honest.

Oct 5 '07 #2
<to*********@gmail.comwrote in message
news:11**********************@g4g2000hsf.googlegro ups.com...
page load runs every time assuming nothing is broken.
Correct, though any code inside Page_Load (and all the other Page_xxx
methods) can be prevented from running at postback by using the IsPostBack
page method...
separating code from the ASP/HTML presentation is considered better
organization, which is why you should use your code behind file.
Not true at all. Inline code or code-behind is simply a matter of personal
perference - it makes not the slightest difference to functionality, or to
the compiler...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 5 '07 #3
The OP was asking, "If so, what is the difference between the Page_Load and
the <% %code at the top of an aspx page?" -- not whether he should be using
codebehind vs. inline code.

The difference is that Page_Load is an intrinsic *event* in the ASP.NET page
lifecycle (there are many others), whereas the <% %code at the top of an
aspx page is called the Page declaration, which sets up the details of the
page class, what class it uses, and other features that each have attributes
you can set.
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

"to*********@gmail.com" wrote:
page load runs every time assuming nothing is broken.

separating code from the ASP/HTML presentation is considered better
organization, which is why you should use your code behind file.

I don't know how the code at the top of the page works in relation to
the event structure to be honest.

Oct 6 '07 #4

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

Similar topics

13
2561
by: z. f. | last post by:
Hi, i have a class that is derived from System.Web.UI.Page, and this is the class i use in my application as PageBase. all other page classes are deriverd from my PageBase instead of the...
2
23474
by: Jeronimo Bertran | last post by:
Hi, I have a page with a very data intensive grid which needs to be automatically refreshed constantly if a change is detected. In order to not refresh the complete page so often, I created an...
0
1607
by: Itai | last post by:
Background: I have four Web Form pages with respective C# code behind files, all in the same project: localhost/vpath1 Page1.aspx Page2.aspx
2
2207
by: Mark Rae | last post by:
I've inherited an ASP.NET app and have been asked to fix the following problem with a page which is used to display and/or delete records from a database. When the page loads, it displays a list of...
13
4571
by: David Lozzi | last post by:
Howdy My following script is not processing at all! <script runat="server"> Sub Page_Load(sender as Object, e as EventArgs) lblWelcome.text = "hello" End Sub </script>
14
13091
by: V. Jenks | last post by:
I'm a little rusty having not touched .NET for 6 months and I can't remember why Page_Load is happening twice in this code: private void Page_Load(object sender, System.EventArgs e) {...
4
2345
by: tshad | last post by:
Is there a way to do put Page_loads on a page? I am trying to setup a Page_Load that just puts a persons name that is logged on at the top of a page the first time a page is loaded. In my...
0
2265
by: jonelling | last post by:
I am having a problem where the page load event is not being fired for certain user controls that I load dynamically in placeholders. Here is what I'm doing in brief, with full test code supplied...
1
6921
by: puja | last post by:
hi all, I have this .aspx page for which the Page_load event occurs twice. I found out while debugging. After searching google, I tried checking with Page.Ispostback method and also had...
11
2680
by: fiefie.niles | last post by:
I am using ASP.NET 2005 and I have a simple form. Page_Load calls a sub mySub that does not do anything (for testing purposes). But, Page_Load gets called twice. On every single ASPX page in my...
0
7237
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7416
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7506
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5062
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4732
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3207
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1571
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
779
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
443
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.