views:

224

answers:

3

Hey all. I have a ASP.NET page that lists a bunch of user accounts.

If I click on a user, an event called LinkChosen is fired, which opens the account view page for that user.

I can also search for users, which narrows down the list. This event is called btnSearch_click

If I click on a user, LinkChosen() is called, and I'm taken to a new page. If I hit the back button, and try to do a search, instead of firing btnSearch_click(), it will still fire the LinkChosen() event and take me to the account I was viewing before pushing back. Doing a search before clicking an account works like it should.

I'm using C# and ASP.NET, and this error appears in IE, but not Firefox.

Does anyone have any ideas?

Thanks.

Clarification edit: The "show single account" action is a hyperlink, not a button. :)

A: 

hmm... this sounds too weird to be true..

I'd check how the event handlers were hooked up (code-front or code-behind) if in codebehind, are you sure they are bound correctly.

Have you tried clearing the browser cache? might be that the back button throws you back to an older version of the page?

just a thought.. could you use plain old asp:hyperlink or a href="" to take you to the page that shows a single account? IE have the ShowAccount.aspx (or whatever you called it) take a query param that tells it which account to show? (instead of using a postback/response.redirect) to get you to the page? I find that making resources available directly on URLs makes developing easier overall. (though this is unrelated to your particular bug)

AndreasKnudsen
From what I can tell they seem hooked up just fine. Especially since they work as they should in all cases but this one, and then only in IE
Ace
Also, I'm already using hyperlinks :)
Ace
+1  A: 

Are you pressing the "Enter Key" when you do a search. If so the first button in the page is usually the one that will get submitted on an Enter keypress.

You can set DefaultButton on the page, or on a panel.

So if you need two buttons to both respond to Enter presses in their respective portions of the page, wrape them both in their own asp:Panel with DefaultButton set.

Iain M Norman
I've tried both. And only the search uses a button, clicking single accounts is made through hyperlinks
Ace
A: 

What I usually see is that the browser forces you to refresh the page after hitting back. So to actually do anything you are re-posting the page, which re-sends the click. Can you use a normal asp:hyperlink, instead of an asp:linkbutton. You will save the postback, and avoid the issue completely.

eglasius
That makes sense. Is there any other ways to avoid this other than switching from linkbuttons to hyperlinks? I don't fully understand the code I'm working on but I think I might break something if I do that. ;)
Ace