views:

969

answers:

3

I have a ModalPopup that will contain a gridview and 4 fields to enter items into the gridview itself.

Is it possible to postback to the server and update the gridview while keeping the modal open?

When you submit the fields and the postback occurs the modal closes has anyone done this before? Someone mentioned a solution using jQuery, but this was long ago.

A: 

I am not sure if this would work, but try to put whatever inside the modalpopup in a UpdatePanel

Please if this works don't hate me after you release, I hate updatepanels too

bashmohandes
I've tried this, no luck
Jreeter
Sorry for that, we should give it a shot anyway :)
bashmohandes
+1  A: 

The key to doing this is going to be using AJAX of some flavor -- Microsoft.Ajax or jQuery Ajax. If the UpdatePanel is not working, then I'd suggest using jQuery to submit back to the server using AJAX. This would involve creating a WebMethod to accept the AJAX post on the server side and instrumenting the client-side with jQuery to send the request/receive the response. Without seeing your HTML it's a little hard to be very specific.

Basic idea:

 $(function() {
    $('#modalSubmitButton').click( function() {
       $.ajax({
           url: 'path-to-your-web-method',
           dataType: 'json',  // or html, xml, ...
           data: function() {
               var values = {};
               values['field1'] = $('#field1ID').val();
               ...
               values['field4'] = $('#field4ID').val();
               return values;
           },
           success: function(data,status) {
              ... update page based on returned information...
           }
           ... error handling, etc. ...
       });
       return false; // stop any default action from the button clicked
    });
 });
tvanfosson
A: 

A kind of ugly option is to force a postback when showing the modal popup in the first place and setting a ViewState["ModelPopupOn"] = true; and then check that on page load and finally postback again and set it to false/remove it from viewstate when closing the popup.

(these kind of issues are why I hate the ajax toolkit)