title: access tempdata in javascript in mvc4
body: <p>I am trying to access TempData in Javascript. but getting null value.
  I am making ajax call to Update the record and i want to display Record updated succesfully message. which will come from UpdateOperation action from the controller.
  but currently it will display null value. I also check with Firebug it shows as follows:</p>
  
  <pre><code>function onComplete(e) {
  
  if (e.name == "update") {
  
  alert('');
  
  } 
  </code></pre>
  
  <p>Here is my code of controller</p>
  
  <pre><code> public class OperationController : BaseController
      {
          /// &lt;summary&gt;
          /// Index action will return template view of the page without data
          /// &lt;/summary&gt;
          /// &lt;returns&gt;Blank Action&lt;/returns&gt;
          public ActionResult Index()
          {
              return this.View();
          }
  
          /// &lt;summary&gt;
          /// Get all Operation from System
          /// &lt;/summary&gt;
          /// &lt;returns&gt;return action result&lt;/returns&gt;
          [GridAction]
          public ActionResult SelectOperation()
          {
              IEnumerable&lt;OperationEntity&gt; operationList = OperationComponent.GetAll();
              return this.View(new GridModel(operationList));
          }
  
          /// &lt;summary&gt;
          /// Method for update operation
          /// &lt;/summary&gt;
          /// &lt;param name="entity"&gt;moduleViewModel to update Module&lt;/param&gt;
          /// &lt;returns&gt;return action result&lt;/returns&gt;
          [GridAction]
          public ActionResult UpdateOperation(OperationEntity entity)
          {
              if (ModelState.IsValid)
              {
                  entity.Log = new BusinessCore.BusinessEntities.LogDetails();
                  entity.Log.ModifiedBy = SessionHelper.UserId;
                  Status status = OperationComponent.Update(entity);
                  this.TempData["AlertMessage"] = status.Message;
                  this.ViewData["_AlertMessage"] = status.Message;
                  return this.View(new GridModel(OperationComponent.GetAll()));
              }
              else
              {
                  return this.View(entity);
              }
          }
      }
  </code></pre>
  
  <p>In my view </p>
  
  <pre><code>@using Telerik.Web.Mvc.UI;
  @{
      ViewBag.Title = "Operation List";
  }
  
  &lt;h2&gt;@ViewBag.Title&lt;/h2&gt;
  &lt;script src="../../../../Scripts/jquery-1.7.1.min.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  //    function onSave(e) {
  //        alert('Record Save Succesfully');
  //    }
      function onComplete(e) {
          if (e.name == "update") {
             alert('@TempData["AlertMessage"]');
              alert('@ViewData["_AlertMessage"]');
          }
          if (e.name == "insert") {
              alert("Operation Inserted Successfully");
          }
          if (e.name == "delete") {
              alert("Operation Deleted Successfully");
          }
      }
      function newAlert(type, message) {
      if (message != "" || message != null) {
          $("#alert-area").append($("&lt;div class='alert alert-success " + type + " fade in' data-alert&gt;&lt;p&gt;&lt;b&gt; " + message + " &lt;/b&gt;&lt;/p&gt;&lt;/div&gt;"));
          $(".alert-success").delay(4000).fadeOut("slow", function () { $(this).remove(); });
      }
  }
  &lt;/script&gt;
  
  @(Html.Telerik().Grid&lt;QuexstERP.BusinessCore.BusinessEntities.SysAdmin.OperationEntity&gt;()
          .Name("Grid")
           .DataKeys(keys =&gt; 
          {
              keys.Add(p =&gt; p.Id);
          })
                      .ToolBar(commands =&gt; commands.Insert().ButtonType(GridButtonType.Image).ImageHtmlAttributes(new { style = "margin-left:0", title = "Add" }))
          .DataBinding(dataBinding =&gt;
          {
              dataBinding.Ajax()
                  .Select("SelectOperation", "Operation")
                  .Insert("InsertOperation", "Operation")
                  .Update("UpdateOperation", "Operation")
                  .Delete("DeleteOperation", "Operation");
          })
          .Columns(columns =&gt;
          {
              columns.Command(commands =&gt;
              {
                  commands.Edit().ButtonType(GridButtonType.Image).HtmlAttributes(new { title = "Edit" });
                  commands.Delete().ButtonType(GridButtonType.Image).HtmlAttributes(new { title = "Delete" });
              }).Width(80).Title("Commands");
              columns.Bound(p =&gt; p.Name).Width(200).Title("Operation Name");
              columns.Bound(p =&gt; p.Description).Width(310).Title("Description");
          })
          .ClientEvents(events =&gt; events
                  .OnComplete("onComplete")
                  )
                      .Editable(editing =&gt; editing.Mode(GridEditMode.PopUp).InsertRowPosition(GridInsertRowPosition.Top))
  
          .Pageable()
          .Scrollable()
          .Sortable()
          .Filterable()        
  )
  @section HeadContent {
  &lt;style type="text/css"&gt;
      .field-validation-error
      {
          position: absolute;
          display: block;
      }
  
      * html .field-validation-error { position: relative; }
      *+html .field-validation-error { position: relative; }
  
      .field-validation-error span
      {
          position: relative;
          white-space: nowrap;
          color: red;
          padding: 10px 5px 3px;
          background: transparent url('@Url.Content("~/Content/Common/validation-error-message.png") ') no-repeat 0 0;
      }
  
      /* in-form editing */
      .t-edit-form-container
      {
          width: 480px;
          margin: 1em;
      }
  
      .t-edit-form-container .editor-label,
      .t-edit-form-container .editor-field
      {
          padding-bottom: 1em;
          float: left;
      }
  
      .t-edit-form-container .editor-label
      {
          width: 25%;
          text-align: right;
          padding-right: 3%;
          clear: left;
      }
      .t-edit-form-container .editor-field textarea
      {
      font-size:11px;
      width:80%;
  }
      .t-edit-form-container .editor-field
      {
          width: 70%;
      }
  &lt;/style&gt;
  }
  </code></pre>