3

I've recently transfered from ASP.NET Web Forms to MVC, I've managed to get my desired textbox values and run some calculations on them, because there isn't much help available for MVC 5 I can't find any information on how to return the value to a textbox in the same view from the controller.

Please help, thanks.

1
  • There are many examples for this and the methods for the older versions still apply. Here's (asp.net/mvc/tutorials/mvc-5/introduction/adding-a-view) even an updated version for a start guide that's not much different from previous versions. Commented Aug 30, 2014 at 19:38

1 Answer 1

3

Store the Initial Value in a ViewBag inside the controller

    ViewBag.InitialValue = "initialvalue";

Then you can access the initial Value inside your View like so

@Html.TextBoxFor(model => model.somename, null, new { @value = ViewBag.InitialValue })

that should do.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.