ASP Life Cycle Problem

  • Thread starter Thread starter john doe Jr
  • Start date Start date
J

john doe Jr

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"]
 
Should the If (Page.PostBack) be If Not Page.IsPostBAck i.e if(!IsPostBack)
, or is this just typo here?
 
As far as I know in C# it is if (!Page.IsPostBack) not If Not
(Page.IsPostBack)

! giving it the Not meaning.


Teemu Keiski said:
Should the If (Page.PostBack) be If Not Page.IsPostBAck i.e if(!IsPostBack)
, or is this just typo here?

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist

john doe Jr said:
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"]
 
Yes, it is a typo, meant if page is not in postback, thats how the code is
written.

Using C# by the way, that is just summary (pseudo) code.


Teemu Keiski said:
Should the If (Page.PostBack) be If Not Page.IsPostBAck i.e if(!IsPostBack)
, or is this just typo here?

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist

john doe Jr said:
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"]
 
Back
Top