473,688 Members | 3,093 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SaveViewState called before events are fired


I have a simple ASPX page called Default.aspx. On it (nested within allot of other stuff) I have a
custom control which inherits from TableRow and implements IPostBackEventH andler.

This custom control hast the following code:

protected override void OnInit(EventArg s e) {
string PostBackRef = Page.ClientScri pt.GetPostBackE ventReference(t his, Item.Identifica tie);
Attributes.Add( "onclick", PostBackRef);

public event MyEvent OnClicked;

public void RaisePostBackEv ent(string eventArgument) {
if (OnClicked != null) {
OnClicked(this) ;

At first this seemed to work fine. The event is triggered correctly when the user clicks the table
row. However, in the eventhandler I create allot of new controls which are dynamically added to the
page. These are rendered correctly but are for some reason not persistent.

To figure out why, I override some methods in the default.aspx page and plot out the entire control
tree to the trace. I did this on:
LoadViewState(o bject savedState)
OnPreRender(Eve ntArgs e)
and also in the event handler of my custom TableRow.

To my astonishment I found that SaveViewState is being called before the event is triggered!
Can someone please explain what I am doing wrong and why?

Thanks in advance,
Aug 8 '08 #1
0 1588

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

Similar topics

by: Aaron Queenan | last post by:
Is there any way to know whether the OnItemCheck is being called in response to a user action (mouse or keyboard) as opposed to the form loading? I have a class which derives from System.Windows.Forms.ListView. Among other features, it enables the checkboxes and overrides the OnItemCheck() method. I have placed this ListView on a form and use form.ShowDialog() to display it whenever the user presses a certain button. If the user...
by: Sam | last post by:
I have a custom control (MyTextBox - taken from Microsoft website) that implements the IPostBackDataHandler interface. It is added to the controls collection of a placeholder control during the Page Load of a main ASPX page. Now if we debug the MyTextBox, we find the order of events like so (during a Posback, of course): OnInit -> OnLoad -> LoadPostData. My question is why does the LoadPostData occur *after* the OnLoad instead of...
by: Ferdinand Zaubzer | last post by:
As far as I know events are fired by invoking a method. Is it possible that events are fired if a boolean property changes its value? Thanks Ferdinand
by: tshad | last post by:
I thought I understood how the SaveViewState is working and was trying to use this (as per some code I found) to detect refreshes. It seemed to be working but I found that the SaveViewState was executing twice on load of page and can't figure out why. I was writing out to a text file in the SaveViewState event and it was writing it twice everytime a page was loaded (whether on an initial load of the page or Postback). I took out the...
by: hmm | last post by:
Hi all I have two problems: Problem #1: I'm using a .NET Form with the property 'FormBorderStyle' set to 'None'. The idea is to completely cover the area of that Form with a UserControl. In order to be able to move that Form around with the mouse I have to implement EventHandlers for the MouseDown, MouseUp and MouseMove event. Now the problem I have is these Events will never be fired because the entire dialog is covered by the...
by: lakepeir | last post by:
Hello, I have combobox with a selectedindexchanged method that seems to be called when starting the application, launching the form with the combobox and making a change in the drop down box of the combobox. Can anyone tell me why the method is called so often? I would only like the method executed when a user makes a change in the drop down box. Am I using the incorrect method. Thanks.
by: alexia.bee | last post by:
Hi All, I have window based app which has two classes. Class A and Clas B Call B Inherits from Class A. Class A has events. How do I cause Class B not to use Class A events. For example: Class A Form_load is being fired even when Class B form is being loaded. There are other events in Class A( Datagridview events) are
by: =?Utf-8?B?SmFtZXMgR2V1cnRz?= | last post by:
On my page, I have one repeater that contains a literal control and a nested repeater. The nested repeater contains a literal control. Both repeaters are databound with only one object (string). But... and this is the crappy part, the nested repeater's events are fired twice. How do I know this? I setup global private counter variables that get incremented on the repeater's ItemDataBound event. The outer repeater is correct and only...
by: Martijn Mulder | last post by:
A general question and a specific one. 1. Is there a Spy utility that shows events for a .NET application 2. What events are fired when calling Form.Show() ?
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...
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,...
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,...
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
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...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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 we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.