Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Professional
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 7th, 2008, 11:01 PM
Authorized User
 
Join Date: Jun 2007
Location: Christchurch, , New Zealand.
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to hericles
Default Preventing page refresh from asp.net button

Hi,
Hopefully I can get some input on how to stop a problem I'm getting in my aspx page.
The page uses some javascript code to increase or decrease amounts shown in asp:labels by clicking add or subtract buttons. Thats all good. I have an asp:button that is supposed to write the final values to a database.
The problem occurs when the button is clicked. The page refresh causes the changes to the label controls to be lost so only the initial value gets saved to the database. I know ways around this (session state, could probably use AJAX) bu what would be better is if the database code ran and the refresh didn't.
Is there anyway to prevent that from happening?

Thank you,
Steve

"I will prepare and one day my chance will come."
__________________
\"I will prepare and one day my chance will come.\"
  #2 (permalink)  
Old October 8th, 2008, 10:55 AM
Friend of Wrox
 
Join Date: Nov 2007
Location: Central Florida, USA.
Posts: 207
Thanks: 2
Thanked 15 Times in 15 Posts
Default

on your page load... place this around the code that loads all the intitial data:

If Not Page.IsPostBack Then

End If

that way the code runs only if the page is initially visited

Jason Hall
  #3 (permalink)  
Old October 8th, 2008, 04:29 PM
Authorized User
 
Join Date: Jun 2007
Location: Christchurch, , New Zealand.
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to hericles
Default

Hi Jason,
Thanks for your reply.
I was already doing that. I found what was causing the issue. As it was a test page, the initial data in the labels was hard coded into the HTML and being altered by the javascript. So, when the page reloaded on the buttn click, it was reverting the labels to the hard coded value each time. Stupid, stupid mistake.

Thanks for your time,
Steve

"I will prepare and one day my chance will come."
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
don't want the page refresh on button click swati_joshi ASP.NET 1.0 and 1.1 Basics 4 July 31st, 2006 04:37 AM
Refresh Page when User Clicks on Back Button testsubject Visual Studio 2005 1 June 26th, 2006 03:46 AM
refresh the page when using back button hastikeyvan Classic ASP Professional 1 May 12th, 2006 11:08 AM
Preventing form submission on refresh rathbird General .NET 2 February 25th, 2004 06:33 PM



All times are GMT -4. The time now is 03:51 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.