Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

button click causes page_load with IsPostBack = false

Status
Not open for further replies.

Jimi2Cool

Programmer
Jul 30, 2007
25
US
I have a web form with 2 user controls each having 2 buttons (they're both slideshow type controls) When any button is clicked, we make it to page_load and IsPostBack=false. This causes one time initialization code to get executed every time a button is clicked. it is my understanding that button clickscause postbacks and therefor should enter page_load owith ispostback=true. What might be causing this behavior? I've been stummped for hours!
 
this is strange indeed. post the code and we may be able to find the problem

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
well, the code's rather simple. it just sets a couple variables on page load like

page_load(object sender, EventArgs e)
{
if(!IsPostBack)
{
Session["ImageNumber"] = 1;
}
}

but, no matter what, the IsPostBack property's always false so init code gets ran every time
 
the session key is very generic. It could be that this value is reset somewhere else in the system. this would create the appearance of a non-postback. When acutally the session variable is reset somewhere else in code.

what about the button click events and the mark up?
have you steped through the code to ensure that the postback value is false.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
i found this issue whilee stepping through. the button click (which does get called and is called before page_load) just incraments that number, saves it back to session. the markup for the button is as follows

<asp:Button ID="btnprev" runat="server" Enabled="False" OnClick="btnprev_Click" Text="Prev" />

oh, btw, autoeventwireup is set to true
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top