0

I use an Ajax Toolkit modal pop-up extender to pop-up a form for collecting information from the user. I intend to send the data collected from the user to the code behind for saving into the database on click of the submit button on that form. I found out, however, that the submit button is not posting back to the saver at all.

I do not want to use any client side coding or a web service.

Is it in any way possible to do post back on a modal pop?

Shittu Joseph Olugbenga
  • 6,396
  • 5
  • 26
  • 37
  • Usually the issue on this cases are that the modal pop-up window is auto-generated outside the form, so the input control is not fire the form. – Aristos Aug 01 '12 at 10:09
  • 'I found out' May I know How you found out?Are you getting any error? – Ishan Aug 01 '12 at 10:11
  • @Ishan: I added break point to the click event handler of the submit button in the code behind. After clicking the button, the was no call to the server-side code. In fact, there was no post back at all. – Shittu Joseph Olugbenga Aug 01 '12 at 11:35

1 Answers1

1

There are two solutions of your problem:

  1. Create form with asp:button in a div, initially set it's display none. At the time of popup just make it visible you can set it's position as your requirement. Then after click on submit button it will behave normally and redirect your page.

  2. It is by using jQuery and Ajax. Create a html form and on submit call a JavaScript function JavaScript function :-

     function on_submit(){
        var pageUrl = 'your_page_name.aspx'
         $.ajax({
           type: "POST",
           url: pageUrl + "/your_web_method",
           data: '{data1:value1, data2:value2}',
           contentType: "application/json; charset=utf-8",
           dataType: "json",
           success: function(msg) {
                    make your success code here
              }
        });
    
      in C# 
        [WebMethod]
        public static void your_web_method(data1, data2)
        {
            // your code to store value in database
        }
    
BenMorel
  • 34,448
  • 50
  • 182
  • 322
Rnk Jangir
  • 711
  • 6
  • 23