?
Solved

Refresh & PostBack

Posted on 2003-04-01
8
Medium Priority
?
444 Views
Last Modified: 2010-04-15
I have a aspx form with some buttons.  When one of the buttons is clicked it executes a stored procedure that assigns some records to the associate logged in.  The problem is that when the page is refreshed by pressing F5 the page is resubmitted and the code is executed as if the button had been pressed again.

Is there a way to determine if the button has been clicked, or if the PostBack is occurring because the browser is refreshed?  Is there another way to handle this situation that I am unware of?

PS.  I am using the HtmlControls library and have tried adding actions in the InitializeComponent() section.

Thanks in advance for any suggestions.
0
Comment
Question by:brisbine
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 18

Expert Comment

by:testn
ID: 8248757
Why don't you handle it through OnServerClick handler?

<input type="button" runat="server" onserverclick="xxxxx">
0
 

Author Comment

by:brisbine
ID: 8249002
When I refresh (F5) the browser window the code gets executed again, the same as if I had clicked the button.  Any other suggestions?
0
 
LVL 2

Expert Comment

by:SegFault
ID: 8251995
can you post your code?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Accepted Solution

by:
krees earned 200 total points
ID: 8257411

try this:

is (!IsPostBack)

{
    // run your code here

}

0
 
LVL 2

Expert Comment

by:dhodge
ID: 8264060
krees is right try :

if (!IsPostBack)
{
 /// Good stuff here
}
0
 
LVL 2

Expert Comment

by:SegFault
ID: 8268355
how about

if(IsPostBack)
  return;

:)
0
 
LVL 2

Expert Comment

by:SegFault
ID: 8268392
you can try using session control maybe?

when the page is first run, set a sentinel flag as a session variable.

Then you can check for the existence of that flag when you start up the page. if it exists, don't run the code to do the updates. if it doesn't exist, set it, then run your code.
0
 

Author Comment

by:brisbine
ID: 8269945
I haven't had time to test this yet, but I am going to give you the points for your helpful comments.

Thanks.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month11 days, 7 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question