Search code examples
asp.net-mvcviewcontroller

Ways to pass data and/or value to View from Controller without ViewData


Just a short question, is there a way to pass data to View without using ViewData and TempData?

Besides model binding, are there any available method(s)?

RT: ViewModel is basically the same as model binding. Is there other way?

Thanks for the wonderful answers guys, much appreciation!


Solution

  • I suggest you to use the best simple way, it is using viewbag

    Example :

    In Controller :

    ViewBag.Test="Hello Brother";
    

    In View :

    <input type="text" id="TXT" name="TXT" [email protected]/>
    

    Or

    <label>@ViewBag.Test</label>
    

    Or Many Examples To Use it is very simple

    i wish this help you brother