Q:

change operation of the controler

My default action code:
      public ViewResult Act(int? id)
       {
        if (id == null)
            ViewData["p"] = GetDefaultView();
        else
            ViewData["p"] = GetEditView((int)id);   

        return View("Index");
       }

My Index view code:
      <!DOCTYPE html><html><head></head><body>
      <div id="content">@Html.Raw(ViewData["p"])</div></body></html>

How it is possible to use instead of ViewData a string ? How I can update #content only by means of $.ajax?

A:

Before being able to use the $.ajax function you will first need to render a view which includes the jquery.js script:
<!DOCTYPE html>
@{ Layout = null; }
<html>
<head>
</head>
<body>
    <div id="content"></div>

    <!-- TODO: Adjust your proper jquery version here: -->
    <script type="text/javascript" src="~/scripts/jquery.js"></script>
    <script type="text/javascript">
        $.ajax({
            url: '@Url.Action("act")',
            data: { id: 123 },
            success: function(result) {
                $('#content').html(result);
            }
        });
    </script>
</body>
</html>

then you should adapt your Act controller action so that it returns some partial view or a Content result:
public ActionResult Act(int? id)
{
    if (id == null)
    {
        return Content("<div>id was null</div>");
    }

    return Content("<div>id value is " + id.Value.ToString() + "</div>");
}

