<asp: Button> event does not fire when inside jQuery-affected element
I am creating ASP.NET with a C # calendar app. When the user clicks on a day, I use jQuery Popup Overlay , which will allow the user to add an "appointment" and click a button to process the entered information in code.
Popup overlay basically hides an HTML element and makes it visible when another element is clicked (great examples at the following link).
Code:
<asp:Button ID="ButtonA" runat="server" OnClick="Button_Click" Text="Button A" />
<asp:Label ID="Label" runat="server" Text="Foo"></asp:Label>
<div id='slide'>
<div id="content">
Content of the 'popup panel'
<asp:Button ID="ButtonB" runat="server" OnClick="Button_Click" Text="Button B" />
</div>
</div>
CodeBehind:
public void Button_Click(Object sender, EventArgs e)
{
Label.Text = "Bar";
}
JavaScript:
$(document).ready(function () {
$('#slide').popup({
//options
});
});
I tried adding the AutoPostBack = "true" parameter to the buttons, but that doesn't matter (should be automatic, no matter, right?). I also tried adding the runat = "server" parameter to the divs, but that made the problem even worse.
I am afraid that I do not understand enough about the nature of the problem to provide more information than this - Sorry!
source to share
It is likely that the jQuery plugin is overriding the button behavior. You can use the onclose callback from the url you provided to have a function like this:
function() {
__doPostBack("ctl00$MainContent$ButtonB","");
}
Otherwise, you might have another button outside of the popup div where you click()
manually execute the event during the onclose
popup event , but that sounds like a hack!
source to share