473,396 Members | 1,789 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,396 software developers and data experts.

OnInit() and Page_Load() called all the time

5
Why when I press a button or select from a DDL, it calls my OnInit() and PageLoad()?
Can I do anything to prevent that from happening,?
Alternatively, is there something like OnExit() where I can undo (or reset) the stuff (my init code) that happens in PageLoad()?
(Now, when my app starts up, I can't tell if it really is the first time or the user just pressed a button...)
Thx,
Oran
[EMAIL REMOVED]
Jul 29 '07 #1
3 3046
radcaesar
759 Expert 512MB
I Don't get the question. Can u explain it in detail ?
Jul 29 '07 #2
ojb
5
Ok, details:
I have this page, ASP, and I put on it a datagrid, several DropDownLists, and lots of buttons.
I have my initiliazing code, like setting a DDL.SelectedIndex to the first item, making some buttons visible and other invisible, etc.
I put a call to MyInit() inside the provided OnInit() routine to do the above.

However, as I found by single-stepping through the program, OnInit() is called when I try to do anything in my page: pressing a button, selecting a DDL item, paging the DataGrid, etc.
I don't want to reinitialize everything when the user, say, wants to scroll down the DataGrid or press a Button on the exisiting data.
I tried to move my MyInit routine elsewhere, like under Page_Load or OnUnload, but the same thing happens, and I have no way to tell when the page is really starting up or just a button was pressed.

There's probably a simple flag to this, but I couldn't find it.
thx,
ojb
[EMAIL REMOVED]
Jul 29 '07 #3
ojb
5
Found it!

if (!Page.IsPostBack)
MyInit();

Thanks all,
ojb
Jul 30 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: | last post by:
I'm trying to better understand the use of inheritance vs. the implementation of a handler. I wanted to ask this question to the newsgroup. Each aspx page is a class which Inherits...
0
by: poi | last post by:
I define controls completely in code in a PrepControls() method. I put the method in here: #region Web Form Designer generated code override protected void OnInit(EventArgs e) {...
0
by: Andy | last post by:
Visual Studio 2003 web form problem using C#. My Page_Load or OnInit routines seems to be called twice for every post back to the server. I think it's the Oninit thats being called twice, the...
8
by: Invalidlastname | last post by:
Hi, We are developing an asp.net application, and we dynamically created certain literal controls to represent some read-only text for certain editable controls. However, recently we found an issue...
4
by: dx | last post by:
If not is it appropriate to place an EnsureChildControls within an objects OnInit method? TIA
1
by: Sally | last post by:
Just confused about when OnInit and Constructor gets called in the parent/child case. Page.Constructor() Page.AddParsedSubObject() <- do all the sub's constructors get called here?...
1
by: Neil Zanella | last post by:
Hello, I would like to ask a question pertaining to programmatic initialization of ASP web controls (as opposed to initialization via standalone attributes and other elements contained in the...
3
by: Beavis | last post by:
I hate to repost a message, but I am still at the same point where I was when I originally posted, and hopefully someone else will see this one... Ok, so I have gone off and documented the...
3
by: gregor.cieslak | last post by:
Hi, how you people handle that issue: you have one page and one control. in your page, you load some kind of object based on the given parameter: Page:
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.