问题
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:
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.
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