Populating Controls via AJAX from JavaScript
I have some JavaScript that displays a <div>
as a modal dialog. This is working fine, but now I'd like to populate some controls on that <div>
using AJAX. I'm trying to determine the best way to utilize AJAX from the JavaScript.
I know t开发者_如何学运维hat I can call __doPostBack()
from JavaScript to initiate the AJAX postback. But then I have to resort to tricks such as injecting some startup script in order to display the modal <div>
from JavaScript after the controls have been populated.
Is there a better way?
If you want to leverage ASP.NET controls, you can make an ajax call to a service that instantiates your control, populates it, renders it, and returns the rendered HTML to your javascript/ajax function.
精彩评论