title: How to pass Controller Element value to View(.cshtml) div element value?
body: <p>I developing WEB API project using .net C#</p>
  
  <p>I need to get the value from controller.cs file and use that value into View(.cshtml) file.</p>
  
  <p>My Controller Code:</p>
  
  <p><strong>HomeController.cs</strong></p>
  
  <pre><code> XmlDocument doc = new XmlDocument();
   doc.Load(httpWebResponse.GetResponseStream());
  
          XmlElement TransID = (XmlElement)doc.SelectSingleNode("/CensusUploadResponse/TransactionID");
          if (TransID != null)
          {
              string ResultID = TransID.InnerText;
  
          }
  </code></pre>
  
  <p>I need to pass the ResultID to Index.cshtml(Ex:ResultID = 17)</p>
  
  <p>MY View .cshtml file code:</p>
  
  <p><strong>Index.cshtml</strong></p>
  
  <pre><code>   &lt;div runat="server" id="CensusuploadDiv"  style="border:1px solid black; width:420px;"&gt;
  
    &lt;/div&gt;
  </code></pre>
  
  <p>I need to assign that ResultID value to CensusuploadDiv.</p>
  
  <p>I try with following method using ViewBag. but's it's not working.</p>
  
  <p>Assign ResultID to ViewBag like below</p>
  
  <pre><code>  if (TransID != null)
          {
              string ResultID = TransID.InnerText;
              ViewBag.Test2 = ResultID;
          }
  </code></pre>
  
  <p>and i get the value in index file like below</p>
  
  <pre><code>&lt;div runat="server" id="CensusuploadDiv"  style="border:1px solid black; width:420px;"&gt;
      @ViewBag.Test2
   &lt;/div&gt;
  </code></pre>
  
  <p>But value not bind to div.</p>