Problem with asp.net and jquery AJAX
<p>I have a folder structure tree i want to reuse on several pages i am building a user control (webForms) for this with a small jquery that gets the html to display from a httphandler. so far so good. I want the user to be able to click a link on a folder i the HTMl i return from my http handler, but it seems that my page is not able to connect the jquery on the page with the jquery returned from the http handler. In my ascx file i have the event handlers for the folder links, and the links are generated in my http handler.</p>

<pre><code>public void ProcessRequest(HttpContext context)
        {
            List&lt;MultimediaType&gt; types = typeRepository.LoadAll(); //load all the types for displaying in the list
            types.ForEach(x =&gt;
                {
                    multimediaTypes.Add(x.Id, x.Name);
                });
            int folderId = string.IsNullOrEmpty(context.Request["folderid"]) ? 0 : int.Parse(context.Request["folderid"]);
            //load folders, from query string, if no folderid in querystring, then default to root
            List&lt;MultimediaFolder&gt; folders = repository.LoadAll(folderId);


            //load files
            List&lt;Multimedia&gt; files = fileRepository.LoadAll(folderId);
            string folderData = BuildFolderList(folders);
            string fileData = BuildFileList(files);
            context.Response.ContentType = "text/html";
            context.Response.Write("&lt;b&gt;" + DateTime.Now.ToString() + "&lt;/b&gt;");
            context.Response.Write("&lt;script type='text/javascript'&gt;");            
            context.Response.Write("$('.folderlink').click(function () {");
            //context.Response.Write("$.get('FolderStructureHandler.ashx', function (data) {");
            context.Response.Write("alert('test');");
            context.Response.Write("});");
            context.Response.Write("});");
            context.Response.Write("&lt;/script&gt;");

            context.Response.Write("&lt;table border='1'&gt;");
            context.Response.Write("&lt;th&gt;&lt;td&gt;Name&lt;/td&gt;&lt;td&gt;Type&lt;/td&gt;&lt;/th&gt;");
            context.Response.Write(folderData);
            context.Response.Write(fileData);
            context.Response.Write("&lt;/table&gt;");
        }
</code></pre>

<p>and the code for my user control is quite simple:</p>

<pre><code>&lt;script type="text/javascript"&gt;
    $(document).ready(function () {
        $.get("FolderStructureHandler.ashx", function (data) {
            $("#folderList").html(data);
        });
    });
&lt;/script&gt;
&lt;div id="folderList"&gt;&lt;/div&gt;
</code></pre>

<p>Both of the methods to write the html is simple:</p>

<pre><code>private string BuildFolderList(List&lt;MultimediaFolder&gt; folders)
        {
            StringBuilder builder = new StringBuilder();
            foreach (MultimediaFolder folder in folders)
            {
                builder.AppendFormat("&lt;tr&gt;&lt;td width='20'&gt;&lt;img src='../Images/folder.png'/&gt;&lt;/td&gt;&lt;td colspan='2'&gt;&lt;a href='#' class='folderlink'&gt;{0}&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;", folder.Name);
            }
            return builder.ToString();
        }
</code></pre>

<p>I have tried to have the jquery .click() eventhandler in the .ascx markup also, but with no success, now i tried to send it with the html from the http handler, still no success. Does anyone have a possible solution to this problem.</p>

<p>Im getting the data loaded on the first time and sees my html table, but when i click a link nothing happens...</p>

<p>Sincerely,</p>

<p><strong>Edit</strong>
Minor modifications to the generated JQuery from the HTTPHandler, it now makes an alert (i had a syntax error), but now im calling the handler each time, but the date time does not seem to change...</p>

<p>new httphandler code:</p>

<pre><code>//load files
            List&lt;Multimedia&gt; files = fileRepository.LoadAll(folderId);
            string folderData = BuildFolderList(folders);
            string fileData = BuildFileList(files);
            context.Response.ContentType = "text/html";
            context.Response.Write("&lt;b&gt;" + DateTime.Now.ToString() + "&lt;/b&gt;");
            context.Response.Write("&lt;script type='text/javascript'&gt;");            
            context.Response.Write("$('.folderlink').click(function () {");
            context.Response.Write("$.get('FolderStructureHandler.ashx', function (data) {");
            context.Response.Write("alert(data);");
            context.Response.Write("});");
            context.Response.Write("});");
            context.Response.Write("&lt;/script&gt;");

            context.Response.Write("&lt;table border='1'&gt;");
            context.Response.Write("&lt;th&gt;&lt;td&gt;Name&lt;/td&gt;&lt;td&gt;Type&lt;/td&gt;&lt;/th&gt;");
            context.Response.Write(folderData);
            context.Response.Write(fileData);
            context.Response.Write("&lt;/table&gt;");
</code></pre>

<p>This creates a popup with the table in, but the date is always the same, as though it is cached or something.???</p>
