title: Return Different Views From MVC Controller
body: <p>I've a MVC application, whose SharedLayout view(Master Page) gives user capability to search. They could search their order by Order No or By Bill no. So there are two option buttons the Shared View along with the textbox. Code is somewhat like this</p>
  
  <pre><code>   @using (Html.BeginForm("Track", "Tracking", FormMethod.Post))
          {
              &lt;div style="text-align: center"&gt;
                  &lt;textarea cols="20" id="txtNo" name="txtOrderNo" rows="2" &gt;&lt;/textarea&gt;
              &lt;/div&gt;
              &lt;div style="text-align: center"&gt;
                  &lt;input type="radio" name="optOrderNo" checked="checked" value="tracking" /&gt;Order No                    &lt;input type="radio" name="optRefNo" value="tracking" /&gt;Ref No
              &lt;/div&gt;
              &lt;div style="text-align: center"&gt;
                  &lt;input type="submit" value="Track" /&gt;
              &lt;/div&gt;
          }
  </code></pre>
  
  <p>So it'll go to TrackingController and Track Method in it and return the view. It works fine for a single search as a View is associated with a controller's methods. It works fine but how could i conditionally return the other view based on the radio button selection.</p>
  
  <p>What i come up with is this</p>
  
  <pre><code> [HttpPost]
      public ActionResult Track(FormCollection form)
      {
          string refNo = null;
          if (form["optRefNo"] == null)
          {
              string OrderNo = form["txtOrderNo"];
              var manager = new TrackingManager();
              var a = manager.ConsignmentTracking(OrderNo);
              var model = new TrackingModel();
              if (OrderNo != null)
                  model.SetModelForConsNo(a, consNo);
              return View(model);
          }
  
          refNo = form["txtConsNo"];
          return TrackByRef(refNo);
      }
  
      public ActionResult TrackByRef(string refNo)
      {
         //what ever i want to do with reference no
          return View();
      }
  </code></pre>
  
  <p>Kindly guide.
  Thanks</p>