views:

29

answers:

1

hi, i have one section in my mvc 2.0 project which doing some processes and after each, return some messages (string) with response.write(). and this messages returned to browser with bad format. i want to return messages to one specific HTML div and add each to end of contents of div tag. now how do this?

this event after each procces raised and message returned to browser.

public void OnProgressEvent(System.Object source, CustomEventArgs customEventArgs)
{
    if (customEventArgs.Level > 5)
    {
        Response.Write(customEventArgs.Message + "<br />");
        Response.Flush();
    }
}
+1  A: 

jQuery is your friend here. If you make an ajax call to say an ActionResult, then you can either return a json object or a partial view.

My preference is to return a partial view and then replace the contents of the div with the resultant html.

So;

public ActionResult jQueryTagDelete(string SomeParametersMaybe)
{
    return PartialView("TagList", tags.OrderBy(x => x.keyword1));
}

And you jQuery code;

    function deleteTag(tagName) {
        $.post("/Admin/jQueryTagDelete", { tag: tagName }, function(RETURNED_HTML) {
            document.getElementById("divTags").innerHTML = RETURNED_HTML;
        });
    }
griegs