Im using MVC 3 asp.net
How can I add an item from ViewBag
to html.TextBox
like this:
@Html.TextBox(\"txtName\",@ViewBag.Par
A View with just
@{
ViewBag.Title = "Index";
}
@Html.TextBox("txtTitle", (string)ViewBag.Title)
works fine with me (notice the cast of the viewbag data to string because Extension methods cannot be dynamically dispatched.) also you will obviously have to change ViewBag.Title to your property
This will work: @Html.TextBox("txtName",ViewBag.Parameters.Name)
assuming that
ViewBag.Parameters.Name has a value
Just to elaborate, you are using @ symbol twice, which doesn't make sense.
Good luck