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

Events, Viewstate, OnPreRender it has to be a bug

Hello All,

I am having a problem with events and the addition of
controls on a page I am developing. First let me tell you
what I have tried and then maybe someone can see something
I missed.

First I tried adding the controls and the event handlers
for my control in the Initialize Components method of my
page in the hopes that it would fire the event before the
Page_Load method was called but to no avail. It seems that
ASP.NET will not let you handle events before the page is
loaded which is expected but it was worth a shot.

Second I decided to go ahead and add my controls and the
event handlers in the Page_Load method and then add the
new controls as the event fired and then push everything
into the control collection at the OnPreRender this worked
as expected and the events fired before the PreRender the
only problem is that any new control added at PreRender
does not maintain its state. Textboxes loose there text
and any handlers attached to the control loose reference
to the delegate they where pointing to. Anyway I need to
find some way to add controls to the control collection
dynamically and get them down to the browser. Right now I
have a real nasty method that just clears all child
controls and calls the Page_Load again and then when
Page_Load creates the control it calls a delegate to give
the control that launched it a handle to it. But there has
got to be a better way.

How can I get these controls added before the page is
render and get them to keep their state information.

Thanks,
Kenton

Nov 17 '05 #1
0 931

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

Similar topics

3
by: Kenton Smeltzer | last post by:
Hello All, I am having a problem with events and the addition of controls on a page I am developing. First let me tell you what I have tried and then maybe someone can see something I missed. ...
5
by: Flare | last post by:
(ASP.NET 1.1) Hi I have a problem with my ViewStates in a userControl. The problem is that the ViewState is not "writte" og changed if you like after editing in my case a textbox. This is...
2
by: Jay Walker | last post by:
I created a custom DataGridColumn based on Marcie Robillard's MSDN Article: Creating Custom Columns for the ASP.NET Datagrid...
3
by: Harry | last post by:
Dear all, It is found that when a webform control trigger an event, Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub This...
3
by: Francois | last post by:
Hi, First of all sorry for the long post but I believe it is quite an interesting as well as advanced and complex problem. I have a problem with the checkbox control I have in my repeater. I...
0
by: tshad | last post by:
I am trying to figure out how to handle a couple of problem using multiple events tied to the same button. Following is the button: <asp:button ID="submitAnswer" CommandName="SubmitAnswer"...
2
by: Oddball | last post by:
I am trying to create and add a number of ImageButtons to a page when a certain event is called. Not only am I suffering from my page running the "Page_Load" event three times, but I can't seem...
4
by: Rolf Welskes | last post by:
Hello, the problem seems simple I have an own webcontrol one property is public bool IsEdit { get
0
by: Walter | last post by:
Hi, can someone please help me with my custom control viewstate problem....I haven't slept for hours trying to get this fixed. I am making two custom controls which will be included on a single...
2
by: Gary W. Smith | last post by:
I have a page that inherits from a base page that is currently overriding all of the On* events. For the most part I'm accomplishing everything I set out to do with the inheritance, but I wanted...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...

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.