event firing

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

Hi,
In a class i built, i fire an event when a field changes. In a webform that
has an instance of the class, the event (from the class) is fired and the
code is executed. However, my webpage does not reload (postback) after the
event fires. How do i get the webform to postback when the event fires
(after the code in the event is done executing)?

Thank you,
Paul
 
In order for an event to fire, a PostBack MUST occur, since the event
handler is on the server side. In other words,if your event handler is
firing, a PostBack IS occurring.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
Paul said:
Hi,
In a class i built, i fire an event when a field changes. In a webform that
has an instance of the class, the event (from the class) is fired and the
code is executed. However, my webpage does not reload (postback) after the
event fires. How do i get the webform to postback when the event fires
(after the code in the event is done executing)?

Why would the form post back? Did you tell it to post back?

What are you trying to accomplish?
 
Oh.....ok....I see what you are saying. And you are correct, the page is
posting back. however, the bahavior i am trying to accomplish (I see that i
was not clear enough in my orginal post) is to have the event fire before
the page loads. Here is the sequence of events that appear to be happening.
(1) Data changes in class (2) call the event (3) Page_Load fires on webform
that containts the event code (4) event executes code

What i need to happen is
(1) same (2) same (3) event executes code then (4) Page_Load

See, in Page_Load, i need the data that is set in the event code.
Currently, when Page_Load runs, it has the previous data from my class.

Any ideas?

Thank you,
Paul
 
Paul said:
Oh.....ok....I see what you are saying. And you are correct, the page is
posting back. however, the bahavior i am trying to accomplish (I see that i
was not clear enough in my orginal post) is to have the event fire before
the page loads. Here is the sequence of events that appear to be happening.
(1) Data changes in class (2) call the event (3) Page_Load fires on webform
that containts the event code (4) event executes code

What i need to happen is
(1) same (2) same (3) event executes code then (4) Page_Load

See, in Page_Load, i need the data that is set in the event code.
Currently, when Page_Load runs, it has the previous data from my class.

This is the way it's supposed to be. Instead of requiring the data in
Page_Load, use it when it's available, in the event.

If you have several events which determine the data you need to operate, you
can do some things in the PreRender event, when all of the PostBack events
and Data Change events will have fired.
 
PostBack events are always processed after the Load event. However, there
are other event handlers that occur AFTER the event handler fires
(Pre-Render, SaveViewState, Render, etc). I would suggest you put your code
into one of them, rather than Page_Load.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
Well I am using a Web Control. When something on the Web Control changes
(user changes data), i take the data from the control and use it in a class
that manages my data.
Actually, this is a little hard to explain so let me get more specific.

Here is an example of something very similar to what i am doing.

Lets say I have a TreeView on the left. The treeview containes car
information (All Makes of Cars and Models as children). When the user
changes the make or model, the data from the tree is synced with an object
that manages the information for all vehicles. When the page is rendered
again, after the new treenode is selected, i want to right had part of the
webform to display information about the current make/model. But i need to
get the information from the object and not the tree. So when the treenode
is changed, i make a change in the class, which fires an event on the
webform that will display information for the current make/model selected.

I am new to ASP .NET, so i may be going about this the wrong way anyway.
But my goal is to have the webform know what information is set in the
object before it renders; thus, the information must be set before
Page_Load.

I really hope this makes sense.

Thank you for your help.

My current delima is that the information is being update (via an event) for
the form after Page_Load fires. So when Page_Load fires, it has the
previous make/model selection (because the event that updates the data is
not fired until after Page_Load)
 
I am new to ASP .NET, so i may be going about this the wrong way anyway.
But my goal is to have the webform know what information is set in the
object before it renders; thus, the information must be set before
Page_Load.

As you say, you're new to ASP.NET. Before you try to get ASP.NET to work
differently, you should first learn how it's meant to work.

I would recommend that you get a book on control development. I usually
recommend "Developing Microsoft® ASP.NET Server Controls and Components"
from Microsoft Press, by Nikhil Kothari and Vandana Datye
(http://www.microsoft.com/mspress/books/5728.asp). If you read it, you'll
learn how PostBack works and how PostBack Data events work.

They all happen after Page_Load.
 
Well I definitely appreciate the advice John. PreRender ended up being my
ticket. I posted yesterday that the prerender had been the key and thank
you and Kevin for all of your help. But I don't see that it ever posted to
the newsgroup.

Thank you again for all of your help.

Paul

Anyway.....thanks again for your help and advice.
 
Back
Top