Reputation: 3568
What I want is while click the button, then the code have to show the Modalbox and then the code-behind continue to process the rest.
The button:
<asp:Button ID="Button1" runat="server" Text="Start"></asp:Button>
Then on code-behind - add the onclick
to Button1:
Generate_Button.Attributes.Add("onclick", "shopModalPopup(); return false;")
And I have an event handler for the Button1.click:
Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
'The process goes here
End Sub
The javascript and the modal-box:
<script>
var grid_modal_options = {
height: 200,
width: 500,
resizable: false,
modal: true
};
function shopModalPopup() {
$("#dialog-form").dialog(grid_modal_options);
$("#dialog-form").parent().appendTo('form:first');
}
</script>
<div id="dialog-form" title="Processing Request" style="display: none;">
<div class="in">
<center><h2> Please wait while we're processing your request. </h2></center>
</div>
</div>
The code above do show the modal-box but then doesn't process the next code on button-click handler. How can I do that? Thank you very much.
Upvotes: 0
Views: 3037
Reputation: 7467
The return false
in your JS onclick handler will stop the default form action from taking place, so your server-side ASP.NET method will never get called.
If you remove the return false
, then the modal dialog will display and the server-side call will be made. However, it won't be a proper asynchronous call, it will be a full-on postback. So whenever the server method finishes its business, the page will do a full refresh. This will have the effect of removing your modal dialog (as the page will be fully rendered again), but I guess this probably isn't what you want. You probably want the modal dialog to display some message to the user when the asynchronous call has finished, with no page refresh, right?
If you do want a proper asynchronous call, I'd suggest using jQuery and a [WebMethod]
page method in your code-behind. Check out this article by Dave Ward for a great tutorial on how to do this.
Upvotes: 3
Reputation: 1127
Why don't you directly put it in a OnClientClick, as shown :
<asp:Button ID="Button1" runat="server" Text="Start" OnClientClick="shopModalPopup"></asp:Button>
Upvotes: 1