On a webform, I've got a Button inside a Placeholder control. Initiallty, I set its Click event declaratively in markup:
<asp:Button runat="server" ID="btnSubmitAgain" OnClick="btnSubmitAgain_Click" CssClass="button iconButton SubmitAgainbtn" />
However, everytime I click this button it bypasses the defined handler (the breakpoint I set is never hit) and behaves like a generic submit
button and causes a postback. My handler clears a session variable and then Redirects back to itself so does not ca开发者_开发知识库use a postback).
I've got an almost identical version of this form which behaves correctly and is, to all intents and purposes, identical code. The handler works everytime in this one :-(
Try as I might I haven't been able to get this to work correctly. Can anyone suggest anything I could look out for? I just don't understand why the event won't fire via the Handler ...
It works fine.
<asp:PlaceHolder ID="PlaceHolder1" runat="server">
<asp:Button runat="server" Text="resubmit" ID="btnSubmitAgain"
CssClass="button iconButton SubmitAgainbtn" onclick="btnSubmitAgain_Click" />
</asp:PlaceHolder>
Note that I added some text to the button so it could be seen: Text="resubmit"
精彩评论