473,756 Members | 2,117 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Two PostBack Events Problem

ASP.NET 2.0 Web Application Project.

I have a class called "SuperPage" that inherits from the
System.Web.UI.P age class. In SuperPage, I
1. Override OnInit (do somecustom Session setup)
2. Override Render (add some controls in the page header, add some
style stuff, etc)

I made a new web page that inherits from SuperPage. I create a
treeview in codebehind, and an empty datagrid in codebehind, and add
them to the Form's Controls collection.

I do not have any markup or control information in the .aspx page
template.

In the Event when a tree node is clicked, I get data and DataBind it
to the grid. However, it appears that the ASP.NET event cycle then
starts all over again, so the Controls and drawn twice, a data query
happens (yes I always get some data back) and the grid is databound.
Worse, the grid always shows zero results.

What could be happening here?

Thanks.
Dec 3 '06 #1
2 1577
OHM
havent done too much with 2.0, but it would seem prudent to add a
debug.writeline statement to the prerender or render in the super page to
see if it is being called even though you think you have overriden it. This
could at least be a starting point.

"xeroxero" <xe******@newsg roups.nospam wrote in message
news:8i******** *************** *********@4ax.c om...
ASP.NET 2.0 Web Application Project.

I have a class called "SuperPage" that inherits from the
System.Web.UI.P age class. In SuperPage, I
1. Override OnInit (do somecustom Session setup)
2. Override Render (add some controls in the page header, add some
style stuff, etc)

I made a new web page that inherits from SuperPage. I create a
treeview in codebehind, and an empty datagrid in codebehind, and add
them to the Form's Controls collection.

I do not have any markup or control information in the .aspx page
template.

In the Event when a tree node is clicked, I get data and DataBind it
to the grid. However, it appears that the ASP.NET event cycle then
starts all over again, so the Controls and drawn twice, a data query
happens (yes I always get some data back) and the grid is databound.
Worse, the grid always shows zero results.

What could be happening here?

Thanks.


Dec 3 '06 #2
Hi,

Follwing might be useful for you to solve your problem.

WHY TO ADD DYNAMIC CONTROLS EVERY TIME?
Please note that the controls added to page dynamically will have to be
added on every trip to the server. You might wonder why do the controls which
have been placed declaritively or at design time does not exhibit this
behaviour but in reality behind the scenes this is what the ASP.Net runtime
is doing by itself. When the page is first requested or its html is modified,
ASP.Net generates a class file that is derived from the requested page and
add the types of declaration like
Page.Controls.A dd
in that file.
So everytime when you request the page, declarative controls get added to
the controls collection of the page. Since you are adding the controls by
yourself you have to add them every time the page is requested by yourself.

WHEN TO ADD DYNAMIC CONTROLS (WHY NOT THE RENDER EVENT)?
It always better for any dynamic controls, to be added in the Page Oninit
event. i.e the lines saying
this.Controls.A dd should be placed in the Page_OnInit event.
The reason for this is, ASP.Net Loads the View State for the Controls just
after this event is finished.
So it expects all the controls to be there before loading view state.
So dont think the controls are being added twice and Render is not the best
place to add them.
Regards,
Hameer Saleem

"xeroxero" wrote:
ASP.NET 2.0 Web Application Project.

I have a class called "SuperPage" that inherits from the
System.Web.UI.P age class. In SuperPage, I
1. Override OnInit (do somecustom Session setup)
2. Override Render (add some controls in the page header, add some
style stuff, etc)

I made a new web page that inherits from SuperPage. I create a
treeview in codebehind, and an empty datagrid in codebehind, and add
them to the Form's Controls collection.

I do not have any markup or control information in the .aspx page
template.

In the Event when a tree node is clicked, I get data and DataBind it
to the grid. However, it appears that the ASP.NET event cycle then
starts all over again, so the Controls and drawn twice, a data query
happens (yes I always get some data back) and the grid is databound.
Worse, the grid always shows zero results.

What could be happening here?

Thanks.
Dec 3 '06 #3

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

Similar topics

5
1458
by: MrMike | last post by:
I have a datagrid containing a drop-down-list. The datagrid contains Edit,Update,Cancel buttons and respective events. Whenever I make a change to one particular field (a drop-down-list in column3), as soon as I click UPDATE the original value which existed at load-time replaces the value I chose. Is this a postback problem, and if so how would I resolve this? Thanks.
6
3824
by: V | last post by:
I have found that when I have a composite control that uses the CreateChildControls method, on a regular page load, Page_Load executes before CreateChildControls, but on a postback it is the reverse. This is causing logic problems and it really bothers me that this sequence of events fires inconsistently. Can anyone tell me why this happens and how we might get around it?
10
9249
by: tasmisr | last post by:
This is an old problem,, but I never had it so bad like this before,, the events are refiring when clicking the Browser refresh button. In the Submit button in my webform, I capture the server side click event and I update session information to track the visibilty of some panels in a wizard type navigation ("Next >>" and "<< Back" buttons).. but the refresh button makes another event firing and takes the whole thing to a Choes.. ...
1
3656
by: Mad Scientist Jr | last post by:
I don't know how this is happening, but a dropdown control I have is resetting to the 2nd value on the list anytime a postback occurs. I have no initiation code outside of If Not (IsPostBack) I have EnableViewState set to true for the control - the control stays populated, it just is losing its selected value. The control is not contained in any panels or anything, just a Web
10
4513
by: Krista Lemieux | last post by:
I'm new to ASP.NET and I'm not use to the way things are handled with this technology. I've been told that when I have a control, I should only bind the data to it once, and not on each post back (basically have the data binding done in the If NOT IsPostBack Then statement). How come? How does this information get preserved? Which raises another question. Becuase I want to get away from the spaghetti code approach, I would like to create...
2
4354
by: RAJ | last post by:
In our multi-tier application, we have several ASP.NET user controls which will update the same data source provided by middle tier logic. In this particular scenario we have one user control displaying the contents of the data source, whilst another control updates the datasource via a command buttons implementation of 'Click', an event raised in the 'Handle Postback Events' stage of the control execution life cycle (via the...
4
4223
by: AIM48 | last post by:
Hi. We have a framework that we work with for our project. So far we have had very good success – basically the frame work wraps many day to day tasks so that they are all included in the project. The framework is built on a modified Page Controller pattern in which a aspx page controls the loading of clients (user controls) into a placeholder (Sort of similar to .net 2.0 Master Pages except that the page loads the client not the client...
1
17044
by: Timbo | last post by:
Hi all, This is my first message here so i'll try and include all the information that will help you help me out, if possible. Basically I am using C# in ASP.NET 2.0 and have a Repeater control in my aspx page with two image buttons, one for an edit command, another a delete command. Here is a cut down code fragment. ...
2
2176
by: Nathan Sokalski | last post by:
I have a DataList in which the ItemTemplate contains two Button controls that use EventBubbling. When I click either of them I receive the following error: Server Error in '/' Application. -------------------------------------------------------------------------------- Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/in configuration or <%@ Page EnableEventValidation="true"...
2
3929
by: John Kotuby | last post by:
Hi guys, I am converting a rather complicated database driven Web application from classic ASP to ASP.NET 2.0 using VB 2005 as the programming language. The original ASP application works quite well, so at times it is tempting just to port parts of it over mostly as-is. In fact, one MSDN article I read suggested using straight HTML wherever possible to make the app more efficient and less resource demanding. On one page there are 2...
0
9462
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9287
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10046
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9886
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9857
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7259
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6542
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3369
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2677
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.