Search code examples
c#javascriptajaxgridviewthickbox

Populating a thickbox via javascript or jQuery


I'm trying to get string data from a web service and populate a thickbox with this data. I feel like this should be the easiest part of the task but so far this is where I'm stuck.

Here is the code in question...


function AjaxRequestHandler(layerName) {
    PageMethods.AjaxRequestHandler(layerName, OnSucceeded);
}

function OnSucceeded(result) {
    // need to display result to the thickbox here...
    alert(result);
}

If I alert as I have above, the text from result is exactly what I want to display in the thickbox. The thickbox also appears but everything I've tried just brings it up empty. My initial gut instinct was to do a document.write, but I can't do that because I get a permission denied error.

Any ideas?

EDIT: I should note that the link with the onclick event running the thickbox is being built up from C# code behind then injected into a GridView. I've tried doing something like what slf has suggested below, but it just shoves data below the link, not into the thickbox.


Solution

  • Solved it! What you said slf was the basic gist of what needed to be done. However, I needed to dig into the ThickBox CSS and find the actual class that was the body that would hold the Ajax data and inject that with the string. So this is the line of code I really needed.

    $("#TB_ajaxContent").html(result);

    Where TB_ajaxContent is a class inside of the Thickbox CSS file, not a class I created.