Here is what you need to do.
1. create a model instead of using view bag
class MyModel
{
public string CompanyName {get; set;}
public string CompanyEmail {get; set;}
public string CompanyPass {get; set;}
public string BranchLocation {get; set;}
public string BranchManager {get; set;}
}
2. set your view to use this model
@model MyModel
3. set your model fields inside your controller
public class MyController : Controller
{
MyModel myModelObj;
public ActionResult regCompany()
{
myModelObj = new MyModel();
myModelObj.CompanyName = "Some company";
.....
.....
return RedirectToAction("regBranch", "SetupQueue", new {companyName = CompanyName ...}
}
public ActionResult regBranch(string CompanyName....)
{
var companyName = CompanyName;
}
}
This is the general idea of how it should be done if you are trying to pass values between two controllers. If you need to display the model inside the view and then pass values to your controller the the controller should return the View object and not RedirectToAction. So you would do this
public ActionResult regCompany(){
return View(myModelObj);}
and inside the view
@Html.TextBoxFor(model => model.BranchManager)
and finally the controller that will receive the values form the view
regBranch(string BranchManager....)
{
var barnchManager = BranchManager
}