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.

ASP Life Cycle Problem



The problem is the following pseudo code causes you need to click buttons
twice to get event.

This is notable via debugging and single stepping.

I can't seem to quite figure out how to do events in ASP where they need to
rerender the page.

I been banging my head on this for 4 days now.


Page_Load

If (Page.PostBack)

Session["currentDir"] = App["rootDir"]

updateTable(Session["currentDir"]

updateTable(currentDir)

string[] dirs = Directory.GetDirectories(currentDir)

foreach dir in dirs

button.Attribs["dir"];

button.Click = myButton_click

tCell1.Controls.Add(button)

Tabl1.Rows.Add(tRow)

myButton_click

Session["currentDir"] = button.Attribs["dir"]

// previously I used this statement but I found it caused the
event to fire twice (cause it wouldn't work period if I didn't have it run
again in page load

// updateTable(button.Attribs["dir"]
Nov 18 '05 #1
3 1521
The following link may be useful to you:

http://msdn.microsoft.com/library/de...nLifecycle.asp

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Michael Johnson Jr." <me@isp.com> wrote in message
news:OO**************@TK2MSFTNGP09.phx.gbl...


The problem is the following pseudo code causes you need to click buttons
twice to get event.

This is notable via debugging and single stepping.

I can't seem to quite figure out how to do events in ASP where they need to rerender the page.

I been banging my head on this for 4 days now.


Page_Load

If (Page.PostBack)

Session["currentDir"] = App["rootDir"]

updateTable(Session["currentDir"]

updateTable(currentDir)

string[] dirs = Directory.GetDirectories(currentDir)

foreach dir in dirs

button.Attribs["dir"];

button.Click = myButton_click

tCell1.Controls.Add(button)

Tabl1.Rows.Add(tRow)

myButton_click

Session["currentDir"] = button.Attribs["dir"]

// previously I used this statement but I found it caused the
event to fire twice (cause it wouldn't work period if I didn't have it run
again in page load

// updateTable(button.Attribs["dir"]

Nov 18 '05 #2
I have read that before, someone wrote an article that was very similar to
that.

Problem is I still don't understand what I need to do.

I tried 20+ different ways of doing things and I can't get anywhere, it is
getting very fusterating to spend 5 days trying to do something so simple.

It all works except for this problem which is causing other problems.

I am basically using the Page_Load event to iterate data, populate table web
contol, which generates buttons on each row and links an event handler to
it. But the event handler won't fire unless this method gets called on page
load even on post back, so that causes the data to reset itself and thus
nullifies the point of the button. (It does work, but when you go down more
than 1 level it fails). If i use a session variable on the button, then I
got to click the button twice (cause the page load generates the page with
the last settings, then the event button changes the default dir, then need
another page load to run the new settings).

When I do a debug on it, this is what I see.

Debug Start.
Page Load
UpdateTable(Session VAR) (Called from Page_Load)
<User Clicks Button>
Page_Load()
UpdateTable(Session VAR) (Called from Page_Load)
Button_Click Event() (Sets session variable)

What this does, is causes it to require a second button click (or some sort
of event to cause the program to do another page refresh with the new
session var since the button click isn't handled before the page load).
"Kevin Spencer" <ke***@takempis.com> wrote in message
news:ub**************@TK2MSFTNGP10.phx.gbl...
The following link may be useful to you:

http://msdn.microsoft.com/library/de...nLifecycle.asp
--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Michael Johnson Jr." <me@isp.com> wrote in message
news:OO**************@TK2MSFTNGP09.phx.gbl...


The problem is the following pseudo code causes you need to click buttons twice to get event.

This is notable via debugging and single stepping.

I can't seem to quite figure out how to do events in ASP where they need

to
rerender the page.

I been banging my head on this for 4 days now.


Page_Load

If (Page.PostBack)

Session["currentDir"] = App["rootDir"]

updateTable(Session["currentDir"]

updateTable(currentDir)

string[] dirs = Directory.GetDirectories(currentDir)

foreach dir in dirs

button.Attribs["dir"];

button.Click = myButton_click

tCell1.Controls.Add(button)

Tabl1.Rows.Add(tRow)

myButton_click

Session["currentDir"] = button.Attribs["dir"]

// previously I used this statement but I found it caused the event to fire twice (cause it wouldn't work period if I didn't have it run again in page load

// updateTable(button.Attribs["dir"]


Nov 18 '05 #3
Michael,

Put your code to populate the table web control into a subroutine. Call that
subroutine in the page load to populate the table with the current session.
Then call the subroutine again to refresh at the end of the button click
event.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Michael Johnson Jr." <me@isp.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I have read that before, someone wrote an article that was very similar to
that.

Problem is I still don't understand what I need to do.

I tried 20+ different ways of doing things and I can't get anywhere, it is
getting very fusterating to spend 5 days trying to do something so simple.

It all works except for this problem which is causing other problems.

I am basically using the Page_Load event to iterate data, populate table web contol, which generates buttons on each row and links an event handler to
it. But the event handler won't fire unless this method gets called on page load even on post back, so that causes the data to reset itself and thus
nullifies the point of the button. (It does work, but when you go down more than 1 level it fails). If i use a session variable on the button, then I
got to click the button twice (cause the page load generates the page with
the last settings, then the event button changes the default dir, then need another page load to run the new settings).

When I do a debug on it, this is what I see.

Debug Start.
Page Load
UpdateTable(Session VAR) (Called from Page_Load)
<User Clicks Button>
Page_Load()
UpdateTable(Session VAR) (Called from Page_Load)
Button_Click Event() (Sets session variable)

What this does, is causes it to require a second button click (or some sort of event to cause the program to do another page refresh with the new
session var since the button click isn't handled before the page load).
"Kevin Spencer" <ke***@takempis.com> wrote in message
news:ub**************@TK2MSFTNGP10.phx.gbl...
The following link may be useful to you:

http://msdn.microsoft.com/library/de...nLifecycle.asp

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Michael Johnson Jr." <me@isp.com> wrote in message
news:OO**************@TK2MSFTNGP09.phx.gbl...


The problem is the following pseudo code causes you need to click buttons twice to get event.

This is notable via debugging and single stepping.

I can't seem to quite figure out how to do events in ASP where they
need
to
rerender the page.

I been banging my head on this for 4 days now.


Page_Load

If (Page.PostBack)

Session["currentDir"] = App["rootDir"]

updateTable(Session["currentDir"]

updateTable(currentDir)

string[] dirs = Directory.GetDirectories(currentDir)

foreach dir in dirs

button.Attribs["dir"];

button.Click = myButton_click

tCell1.Controls.Add(button)

Tabl1.Rows.Add(tRow)

myButton_click

Session["currentDir"] = button.Attribs["dir"]

// previously I used this statement but I found it caused

the event to fire twice (cause it wouldn't work period if I didn't have it run again in page load

// updateTable(button.Attribs["dir"]



Nov 18 '05 #4

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

Similar topics

1
by: athos | last post by:
Hi all, Believe you have sound experience in development, however, if we look at the whole Software Development Life Cycle (SDLC) of the project, say, 1. Project Initiation, 2. Gathering...
2
by: cmbardon | last post by:
I have a C# application that uses a C++ COM exe server, and I've noticed some strange behaviour with the life cycle of the object. In my .net app, I create an instance of the COM object (generated...
2
by: prem | last post by:
Hi, Iam new to ASP.NET. Any one can please give full description about ASP.Net life cycle. Thanks in Advance, Prem.
6
by: jim | last post by:
Hi All, I like to know the life cycle of an ASP .NET Application( incudieng server application, such as .NET Web Service). That means from initialization to fully running and how to reboot it or...
12
by: TB | last post by:
Hi All: I am trying to create a variation on the standard datagrid, whereby the datagrid is only shown after pressing some buttons. This reason for this is that I would like to use the same...
16
by: bharathi.vempati | last post by:
hi Can any one explain me the life cycle of C from source code to process termination. please make it fast k bye -ramya
3
by: Griff | last post by:
I want to build a set of compiled user controls to incorporate into a web site. The majority of user controls will be placed on specific web page and these controls would share a common...
3
by: HP | last post by:
Hi there The problem of dynamically created controls vs viewstate is widely known one. To access values of controls they have to be recreated on Page_Load. Unfortunately it causes many...
1
by: =?Utf-8?B?U2FtZWVrc2hh?= | last post by:
I vaguely know that HTTP Post does not send all the data (hidden fields?) along with the request. I would like to know the stage in ASP.Net application life cycle where the POST data is read - is...
4
by: lander | last post by:
I've read the page life cycle thing in msdn, still, i'm getting a bit confused of thinking how all the things are going under the hood... I know that when page loading, that the controls'...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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.