简体   繁体   中英

passing data from Ajax Modal popup extender to a textbox on the asp.net page

I have a Ajax modal popup that displays a set of options for the user. On submit button click event on the ajax modal popup, i need to pass the user selected data back to a text box on the user control (which has the modal pop up) on the calling page.

Structure/flow is as follows. There is a page and two user controls. One is a search control that has another user control that contains the user options. The master page has the search user control. When the user chooses an option in a dropdownlist in the search control, it does a mpe.Show of the user control with options. User makes his selections and hit submit button. In the button click event in the popup, i delegate an event back to the search user control which tries to set the value in one of its text boxes. Everything is going fine until this step and i can see the value but the text box never changes. It seems like the user control is already rendered and the changes are ignored. Any idea how I can get around this?

In short, how to get back the data to a control from an Ajax modal popup.

Use jquery - when the user clicks a button on the modal - use jquery to set the value field to be the data that the user has selected.

eg

$('#modalButton').click(function() {
   var userData = $('#tbUserData').val();    

   $('#textBoxElsewhere').val(userData);
});

for anybody's future reference, i did a work around for this. What was happening is that, on the final button click postback, the page/parent user control load events run first and then the button click event.. so the changes that were being made in the button click event did not make it back to the parent user control on the page.. i had to add a middle step to display the user selections for approval and force the user to hit a final confirmation hit. On that post back, the changes were already available for the parent user control, and not have to wait for the button click event to trigger to grab the data. I'm sure there is a better way to do this but this is what I could come up with.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM