I want the user to click the link then the window pops up, but I want the data inside the w开发者_StackOverflow社区indow to be pulled from a database, and I need to repeat this process for 5 links that are also pulled out of a database. Say the most popular items for the month. My question is how would this be best accomplished? Jquery, or AJAX. I am just trying to see which would be the easier way to go about coding this with .net and C#. If anyone has any tutorials related to this at all that would be wonderful. Thank you guys in advance.
The most simplest solution I think you can either just code the window as a separate page asp.net page. In the code behind you can get the data from the database. The link would just open this page as a popup modal window. When the page executes, it will get the data from your database.
A more elaborate solution if your doing something more fancy say if you want to use jQuery dialogs would mean that you would have to get the content of the dialog using ajax, which can be called when the user clicks the link.
You can use JQuery with the Ajax API - use the http://api.jquery.com/jQuery.get/ method to call a web service e.g. a .net wcf service over http. In the jquery script you can call the .get(...) method that calls your service (that then gets the data from the database). With the returned data you can replace the contents of a div element, which then you can use for a jQuery dialog.
$.get(WEB_METHOD_URL,
{ param1: XXX, param2: YYY },
function (data) {
$('#ID_OF_DIV').empty().append(data).dialog('open');
});
精彩评论