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

Two PostBack Events Problem

ASP.NET 2.0 Web Application Project.

I have a class called "SuperPage" that inherits from the
System.Web.UI.Page 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 1561
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******@newsgroups.nospam wrote in message
news:8i********************************@4ax.com...
ASP.NET 2.0 Web Application Project.

I have a class called "SuperPage" that inherits from the
System.Web.UI.Page 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.Add
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.Add 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.Page 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
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...
6
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...
10
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...
1
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) ...
10
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...
2
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...
4
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...
1
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...
2
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....
2
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...

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.