Doing post back on an ajax toolkit modal popup extender

依然范特西╮ 提交于 2019-12-14 03:17:55

问题


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?


回答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
        }
    


来源:https://stackoverflow.com/questions/11756923/doing-post-back-on-an-ajax-toolkit-modal-popup-extender

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!