0

Well, I'm not sure what the problem is exactly but my postback is not firing properly. I am using URLRewriting.Net and have it configured in an extension-less manner. So, the page I am working on is http://xxx.xxx/products and it rewrites to /products.aspx.

There's a button on my masterpage that's for a site search. There's a button on my contentpage as well. If I click the contentpage button, the page looks like it posts but my control events don't fire, just the page load event fires.

If I remove the button on the masterpage, it works fine. The masterpage button is wrapped in a panel with the defaultbutton set.

Or, if I leave the button on the masterpage and browse to the physical URL not using a rewritten URL, then it works fine.

What am I missing?

Edit: I have traced this to a PostBackURL being set on the button on the masterpage that was to send the postback to /search/default.aspx. Removing the PostBackURL fixes the problem and events fire properly. But, why is this happening and how can I fix it? Thanks.

shamazing
  • 730
  • 4
  • 9
  • Run fiddler and check out your post __eventtarget – TheCodeKing Sep 08 '11 at 18:20
  • The __eventtarget has a blank value under all three of the scenarios listed in my original post. It's blank in situations where it works and where it doesn't. – shamazing Sep 08 '11 at 19:03
  • Can you post the aspx? `asp:button` doesn't use `__eventtarget`, which could explain why it's blank. – TheCodeKing Sep 08 '11 at 19:17
  • I'm grateful for your help, but would prefer not to post the aspx. There's nothing there to look at anyway. The only event for the content page is the _Click event for the button on the content page. There's no code behind the masterpage or its button since it's set with a postbackurl of the search.aspx page. – shamazing Sep 08 '11 at 19:26
  • Well it's hard to help without seeing the code, you can/should strip it back to the most simple example that doesn't work. Need to see what controls you are using etc. Different buttons types behave in different ways, and can have different issues. – TheCodeKing Sep 08 '11 at 19:31
  • Well, with some additional testing, I can say that it appears to be the PostBackURL of the button on the masterpage. I removed that and now it appears to be working. Any thoughts? I don't understand the correlation between that and the URL rewriter. Accessing the underlying ASPX without URL rewriting works with the PostBackURL set on the masterpage button. – shamazing Sep 08 '11 at 19:43
  • What was the PostBackURL set to? With rewrite, and without. – TheCodeKing Sep 08 '11 at 19:53
  • It was set to /search/default.aspx which was an existing code file. I was not using rewrite yet, search is still in development. – shamazing Sep 08 '11 at 20:13
  • If you can post a stripped down version of the aspx might be able to help, otherwise I'm just guessing. The only thing I can think is that you might be using 2 asp:buttons, and ASP.NET is confused about which caused the postback, but doesn't really make sense - need to see it. – TheCodeKing Sep 08 '11 at 20:46

1 Answers1

0

Here's a possible answer to your problem - I'm guessing it may be related.

It can be caused by breaking changes in ASP.NET 4.0, where the action attributes is rendered empty.

Community
  • 1
  • 1
TheCodeKing
  • 19,064
  • 3
  • 47
  • 70