开发者

how to update specific div data through ajax in asp.net mvc

开发者 https://www.devze.com 2023-01-01 06:17 出处:网络
how to updat开发者_StackOverflowe specific div data through ajax in asp.net mvcYou may take a look at the UpdateTargetId property:

how to updat开发者_StackOverflowe specific div data through ajax in asp.net mvc


You may take a look at the UpdateTargetId property:

Controller:

public ActionResult SomeAction()
{
    // you could return a PartialView here if you need more complex HTML fragment
    return Content("<span>some content</span>", "text/html");
}

View:

<div id="result"></div>
<%= Ajax.ActionLink(
    "Update div test", 
    "SomeAction", 
    new AjaxOptions { UpdateTargetId = "result" }
) %>


Another way might be to return a partil view from your controller and place the resultant html into the div.

    public ActionResult jQueryTagFilter(string filterBy)
    {
      //Do stuff
      return PartialView("TagList", tags);
    }

Then in your html;

    $.post("/Admin/jQueryTagFilter", { filterBy: filter }, function(newUserListHTML) {
        $("#divTags").fadeOut(300, function() {
          $"#divTags").innerHTML = newUserListHTML;
          });

        $("#divTags").fadeIn(300);
    });
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号