 |
| ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

October 4th, 2004, 12:27 PM
|
|
Registered User
|
|
Join Date: Oct 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Page_Load method not executed on initial load
Hello Guys:
I have a standard aspx page with textboxes populated through a dataset.
I have a button that updates the fields from the textboxes to the database using sqlcommand without going through the dataset and then redirects to the home page. This is basically a user's personal information update page.
If I use a hyperlink on the homepage to go back to the edit page, the textboxes are not populated with the new information. I am calling the population function in the page_load event handler (if not postback).
I placed a breakpoint on the even handler and noticed that the breakpoint only catches after I'm on the page and press the re_load button on the browser, and then it is executed.
Also strange, is that the code inside the if(not ispostback) is executed and then my text boxes are filled with the new values.
I would like this behavior to take place when i revisit the page automatically instead of me having to press the reload button.
Any help would be greatly appreciated.
|
|

October 4th, 2004, 02:40 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Could you post any code? In addition, if you want the behavior to happen when the page is revisited, might you want if (Page.IsPostback)?
Brian
|
|

October 4th, 2004, 03:06 PM
|
|
Registered User
|
|
Join Date: Oct 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
Fill the fields with User's information from database.
}
}
private void Submit_Click(object sender, System.EventArgs e)
{
Update the database with textbox values and Response.Redirect("Homepage.aspx").
}
What I mean by leaving the page is that after the button is clicked, the database is updated, I was redirected back to the homepage. (another aspx page) If I go back to the Info page, by clicking a hyperlink using response.redirect, I get to that page but I see the values in the text box as if nothing was changed from the first visit. If I press the reload button on the browser, then the code inside the Page_load If(!ispostback) is run and then i see the fields updated.
|
|

October 4th, 2004, 03:18 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Are you specifying output caching for that page?
|
|

October 4th, 2004, 03:23 PM
|
|
Registered User
|
|
Join Date: Oct 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
No, there is no output cache on this page or anywhere else in the project.
|
|

October 23rd, 2004, 09:19 AM
|
|
Authorized User
|
|
Join Date: Oct 2004
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
put your page in trace mode, and see what it is happening
wagner reatto
|
|

October 25th, 2004, 07:44 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Hey,
Could you also post any necessary additional code, such as how you do the redirect?
Brian
Brian
|
|

October 25th, 2004, 03:41 PM
|
|
Registered User
|
|
Join Date: Oct 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thank you all for your help. Apparently it was a setting on my browser that my tech set that said to "always use local copy".
This was what caused this weird problem.
Regards.
|
|
 |