Confused about events and when they get fired.

A

AndrewMBaldwin

I have a grid control (inherits from Placeholder) that has a few
buttons on it. On this grid there is a filter form, which allows the
user to filter/search the table for specific information. My problem
is, that the order in which the event gets called. What is basically
happening is that the control is instantiated, I call my initialize
method, then I wait for the user to call GenerateGrid, in case they
wanted to make any last minute changes to the grid that I don't have a
constructor for, or possibly add/remove event handlers from the grids
buttons, etc. The problem is that unless I actually generate and add
the grid control to a page, the filter event never fires off. And then
when it does, I generate the grid, add it to the page, then the filter
event fires off and REgenerates the grid. I have tried putting the code
that calls the GenerateGrid function in the pages pre-render method,
last step before rendering, but then the filter event never even fires.

I know this sounds complicated, but please bear with me and hopefully
we can get this figured out...

AB
 
B

Bruno Alexandre

now I got confused :-(

without confusing me more ... what's the final propose?
 
M

multiformity

The final purpose is to use my custom grid control, with built in
headers, footers, pagers and filter form on my pages. The microsoft
grid is nice and all, but my grid works with any table in the database,
without any extra setup. All of the captions and help topics associated
with tables and fields are in the DB, as well as all the field types.
Because it is all in there, I can use one grid control and one filter
form in one page, not making a different ASPX page for each table in
the DB. I am working on the opensource project located at
http://www.codeproject.com/aspnet/RapidWebAppDev.asp


Basically all of the captions, add/edit forms and all of the other
common things that most people who create grids have to implement are
all defined in metadata. I am now to the point where I am customizing
the grids behavior by changing the button events before they are
generated and placed in the placeholders control collection. For
example, I have a checkbox column that you can display, and by default
under that collumn, I have "edit selected rows" and "delete selected
rows" buttons. In one case, I want to remove those buttons and, while
still using the grids checkboxe column, do something entirely different
with the selected rows.

So, again, the problem is that a button is causing a post back, the
grid is generating itself once, THEN firing the event handler for the
button that caused the postback in the first place, then it has to
generate itself again. I am trying to avoid the creation of the grid
(building a table with 100 some odd rows of content and buttons), just
to have the filter event fire, and regenerate a different grid, with
the main difference being the rows that it displays...

I looked into the bubble event, but I can't get the onbubble event to
fire unless I actually add the grid control to a page (thus requireing
that I generate the grids "table" member, and populate the base
placeholder classes Control Collection with the appropriate controls,
just to have it generate itself again).

I basically want the grids filter button event to be the first thing
called on the postback, pretending that the grid is still in memory on
the server I guess. It doesn't look like this is possible, although I
was told to pretend that ASP.Net is not a stateless environment like
previous versions of ASP...

Please let me know if I am making sense or not...

Andrew Baldwin
 
B

Bruno Alexandre

well,

I liked to help you, but I will not download that control just to help you
with that, sorry... to much work!

I never have any problem with sql/grid... I always show a GridView in the
page, cause I just love that control, and I do everything with it (took me a
while, but now I'm unstopable) :)

in page.load ... in page.ispostback I get the data and fill up a DataTable,
and since then to the user click Save back to Database I never ask anything
to the DB... always use the DT to sort, filter, add and remove

using a DT I could create my own Database Class to do all of that moves and
procedures ... I still perfer workin' like that cause using other guys
controls... there is always a thing we wanna add or remove and then we need
to investigate to see how can we do that... it will take more time is I
build one time only my class... and everytime I need to add something, I
just go to the class and add it, and it will be available for future
websites, or even in the same website ...

I perfer this way.
 
M

multiformity

Hmm, maybe you can answer this, at what point does a buttons click
event fire, and does it have to be added to the pages control
collection for it's fire event to be called? I have found that it runs
like so:

Derived Page class's onload fires
Grid is initialized, controls generated and put in the placeholders
control collection
BasePage's onload event fires
Grid's filter event is called, and grid is subsequently regenerated,
which is a lot of overhead, The page only gets rendered once, but it
physically constructs the grid two times.

I tried to do it like so

Derived pages onload fires
The derived onload initialized the grid, but does not tell it to
generate it's controls (Well, it doesn't generate the actual table, all
of the buttons are instantiated and their events wired, they are just
not added to the placeholder's control collection).
BasePage's onload event fires
Derived pages prerender event filres, and tells the grid to generate
it's controls and put them on the placeholder, but then the grids fire
event doesn't fire.

I guess the next step is to have the page load add the buttons to the
page in the derived pages onload event, even if there is not a table on
the page to display it's associated data...

Again, the Bubble event is never fired unless the grid is populated,
the controls generated, then added to a page's placeholder.


AB
 
B

Bruno Alexandre

a button event can execute as PostBack or CallBack...

postback will execute the hole page, and for that the hole events for the
page ... (that's why we use sometimes if page.ispostback

the callback will execute a Script Function (like AJAX) normally in
Javascript, like rollover in images... you can build everything running in a
callback, see atlas website for a quick look on what you can do without a
page refresh

Atlas : http://atlas.asp.net/
Atlas Toolkit : http://atlas.asp.net/atlastoolkit/
 
M

multiformity

I have looked at Atlas already and have not seen anything like that,
any examples of exactly one would do that?

AB
 
B

Bruno Alexandre

http://atlas.asp.net/atlastoolkit/ConfirmButton/ConfirmButton.aspx

the ConfirmButton runs a callback to the server and execute a function, in
this case something like:


label.text = "You clicked " & buttonClickedName.text & " you're safe"

without any postback to the page (you can see that the fucntion is performed
without refreshing the webpage).
and tha'ts what you want, a callback button/or link to perform your
operation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,836
Latest member
login dogas

Latest Threads

Top