Hi MrPattison,
Check this example. Now please take its reference and correct your code.
Controller
public class HomeController : Controller
{
// GET: Home
public ActionResult Index()
{
ViewBag.PanelShown = false;
return View();
}
[HttpPost]
public ActionResult Index(string showHide)
{
ViewBag.PanelShown = Convert.ToBoolean(showHide == "" ? "false" : showHide);
return View();
}
}
View
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
@using (Html.BeginForm("Index", "Home", FormMethod.Post))
{
@Html.TextBox("showHide", "", new { @class = "form-control" })
<br />
<button type="submit" class="btn btn-primary">Submit</button>
}
@if (ViewBag.PanelShown != null)
{
if (ViewBag.PanelShown)
{
<hr />
<div class="form-group row">
<div class="col-md-offset-2 col-md-10">
Thank you for your order.
</div>
</div>
}
}
</body>
</html>
Screenshot