I think my title says it all. I have a modal dialog showing up and the user can make some changes and then click a 'Save' button. I need that to totally post back the whole page. What would you suggest? I just assumed the button would fire off regardless of the jQuery.
views:
84answers:
2
+3
A:
You could force a post back from Javascript:
__doPostBack(id,'');
To do this directly from a control, like a button, use OnClientClick:
<asp:Button id="myButton" runat=server OnClientClick="__doPostBack(id,'');" />
Matthew Jones
2010-05-07 21:12:49
how do I tie that into my ASP.NET button click?
Matt
2010-05-07 21:13:48
@Matt check my edit :).
Matthew Jones
2010-05-07 21:16:16
?? If you have an asp.net button click then that will already be posting back .....
James Westgate
2010-05-07 21:26:32
@James Westgate: Not necessarily, if you have a declaration like this `<asp:Button runat="server" ID="btn1" />` it will generate the following markup `<input type="submit" id="ctl00_cpMainContent_btn1" value="" name="ctl00$cpMainContent$btn1">`. It looks like jQuery UI dialog basically rips the contents of the dialog out of it's place in the DOM and attaches it as the last element in the body (outside of the form asp.net puts on the page). Since the button is outside a form, it won't cause a submit.
R0MANARMY
2010-05-07 21:39:16
you could also check the source of the dialog js, and you should find a line similar to $('body').append(....) and change that to $('form').append(...) so your asp.net button in the dialog remains in the form and can initiate a postback.
derek
2010-05-07 23:56:59
+1
A:
put an asp button on the page and hide it with css in the onclose event of the dialog window, call aspButton.click
<asp:button id="myButton" runat="server" OnClick="myButton_Click" style="visible:hidden;" />
...
$('#' + <%= myButton.ClientID %>).click();
yamspog
2010-05-07 21:33:43