When I refresh my browser it calls ASP:Button, how to void it?
I have a problem with my asp.net in vb.net when I putsh the "refresh", "reload" button from my browser (Mozilla, Internet Explorer, Opera), my page thinks that I clicked again my ASP:Button, what I can do to avoid it, I already tryed inserting if page.isPostBack then ... but it didn't work
did you already click that button and the page fired a script, then you are clicking refresh? Its resending the post data, what you can do is when you click that button, have it do a response.redirect to another page then fire the script onload of that other page, that avoids post data. Either that or just use an html button and have the form action be the script on the other page.
The problem about redirecting to another page is that when I trigger the button, I'm adding a row for each click so I really need to stay in courrent page, also redirecting to the same page will not work because I'm using Shared (Static) variables what are cleaned when not page.IsPostBack
could you pass the variables to the next page with a query string? Because hen you refresh a page and you are swapping out elements or changing elements, all the events the user performed must happen again, which is going to throw errors if a record no longer exists or something.
Originally posted by roteague Also, using static (shared) variable isn't a good idea. If you need to maintain a varables state across post-backs use a ViewState to store the value in.
I would rather keep it in a hidden input and not use viewstate. But if you use a client side button it is still going to have to resend the page in order to execute a server side script. So the form action is going to come into play, but if it is a server side form the form action should be the page you are on so that would not be a problem.
But I do not like keeping a lot of stuff on one page, when you can it is often good to split stuff up, to get rid of post data complications.