Wrox Programmer Forums
|
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
 
Old October 7th, 2008, 11:01 PM
Authorized User
 
Join Date: Jun 2007
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.\"
 
Old October 8th, 2008, 10:55 AM
Friend of Wrox
 
Join Date: Nov 2007
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
 
Old October 8th, 2008, 04:29 PM
Authorized User
 
Join Date: Jun 2007
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."





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.