logo
down
shadow

ASP.NET MVC pass information from controller to view WITHOUT ViewData, ViewModel, or Session


ASP.NET MVC pass information from controller to view WITHOUT ViewData, ViewModel, or Session

By : user3862141
Date : November 22 2020, 07:01 PM
fixed the issue. Will look into that further In general, I'd recommend being explicit about what your views are allowed to access. Thus I'd recommend that you put this data in ViewData from your controller, and then pull it out of ViewData from the view. That keeps the line of communication between your controller and view in one place and simple.
However, if you really want to access the Session from the view, you can.
code :


Share : facebook icon twitter icon
How to pass information from controller to viewdata? asp net mvc c#

How to pass information from controller to viewdata? asp net mvc c#


By : Vincent Norton
Date : March 29 2020, 07:55 AM
hope this fix your issue Well, I did it like this:
I created a "view-model" of (my custom) data grid which contains infos about the current page, page size, etc.
code :
using System.Collections.Generic;

public class GridContent<T>
{
    public IEnumerable<T> Data { get; set; }
    public int PageIndex { get; set; }
    public int TotalPages { get; set; }
    public int TotalItems { get; set; }
}
return View(new GridContent<Entity>()
            {
                Data = entityEnumeration, // your actual data
                PageIndex = pageIndex,
                TotalItems = totalItems,
                TotalPages = totalItems / pageSize + 1
            });
<%@ Page Title="SomeTitle" Language="C#" Inherits="System.Web.Mvc.ViewPage<GridContent<Entity>>" %>
Using ViewData to pass string from Controller to View in ASP.NET MVC3

Using ViewData to pass string from Controller to View in ASP.NET MVC3


By : Денис Кукушкин
Date : March 29 2020, 07:55 AM
this one helps. You are not rendering a view, you are redirecting. If you wanted to pass some information tyo the view you need to return this view after adding it to ViewData:
code :
[HttpPost]
public ActionResult DisplayForm(UserView user)
{
    //some  data processing over here
    ViewData["choice"] = "Apple";

    return View();
}
[HttpPost]
public ActionResult DisplayForm(UserView user)
{
    //some  data processing over here
    TempData["choice"] = "Apple";

    return RedirectToAction("Next", "Account");
}
How to pass viewData back to the controller from partial view?

How to pass viewData back to the controller from partial view?


By : aniketkhare
Date : March 29 2020, 07:55 AM
Hope this helps Calling Html.RenderAction or Html.Action is largely the same as Url.Action. There's many different overloads, but essentially, the first parameter is the action name, the second parameter is going to be either the controller name or an anonymous object of route values, and the third parameter will be an anonymous object of route values if the second parameter was used for the controller name.
Anyways, whatever you pass in the route values will be used to find and call the associated action, which includes parameters for the action. So, for your example:
code :
Html.RenderAction("FinishedCalibrationForm", new { obj = obj })
Ways to pass data and/or value to View from Controller without ViewData

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


By : Marlon Vidal
Date : March 29 2020, 07:55 AM
this will help i suggest you to use the best simple way , it is using viewbag
Example :
code :
Viewbag.Test="Hello Brother";
<input type="text" id="TXT" name="TXT" value=@ViewBag.Test/>
<label >@ViewBag.Test</label>
Using ViewData to pass data from Controller to View

Using ViewData to pass data from Controller to View


By : Dilyara Ziyatdinova
Date : March 29 2020, 07:55 AM
I hope this helps . Since you have set some property on the ViewData on the Controller, you will have it available on the ViewData on View. On the other hand, you have the TempData which is used when you need to transfer information between requests to another route (redirects to an action). For sample:
Related Posts Related Posts :
  • ASP.NET MVC - creating and handling with URLs with Greater Than and Less Than characters
  • ASP.NET MVC: calling a controller method from view
  • Strategy in exporting to Excel with formatting from ASP.NET?
  • building an ASP NET MVC site, should i go with linq to sql?
  • ASP.NET MVC not serving default document
  • Passing parameters to telerik asp.net mvc grid
  • ASP.NET MVC application architecture "guidelines"
  • ASP.NET MVC 2 validation using DTOs instead of domain entities
  • Page Redirect when session end in ASP.Net MVC
  • Is there simple way how to join two RouteValueDictionary values to pass parameters to Html.ActionLink
  • How does Select statement works in a Dynamic Linq Query?
  • Spark view engine - why there is no VS integration in version 1.1?
  • How to fix a NHibernate lazy loading error "no session or session was closed"?
  • ModelBindingContext ModelName
  • ASP.NET MVC TempData used for wrong request
  • MVC actionlink posting List of complex type
  • Displaying an asterix when using Html.LabelFor() with a Required property
  • Could model unit tests be truly independent and how [ASP.NET MVC]
  • How to create dynamic view page in mvc2.0?
  • Can't place a breakpoint in asp.net master page file
  • Saving state between actions
  • Custom Authorization/Authentication with Repository pattern
  • How to execute SQL query in a new database?
  • Themeing and Master Pages
  • Hosting WCF Services in ASP.NET MVC Web Application
  • How do you link to an action that takes an array as a parameter (RedirectToAction and/or ActionLink)?
  • What logic can go in the view? (MVC)
  • Asp.net mvc class reference in session
  • Unit testing a controller in ASP.NET MVC 2 with RedirectToAction
  • How to edit the user details stored in aspnetdb without asp.net web administration tool?
  • ASP .net MVC Jqgrid data binding
  • using two submit buttons inside single form
  • How can I use routing in ReactJs?
  • Error checking in controller in ASP.NET Core MVC
  • MVC Mutilple Tables SQL question. What is the best practice
  • How to use Asp.net MVC Core with Asp.net Identity Core and WebAPi Core?
  • EF Core - Repository, Model or View Model
  • MVC Web API Angular App ('http://localhost:4200' has been blocked by CORS policy)
  • Convert Datetime from mvc to Oracle in multiple Date/time format?
  • Is it good way to update data in ASP.NET MVC?
  • Kentico 12 PageBuilder missing reference
  • Mutiple shared layout mvc
  • Preventing from manipulation of disabled fields using developer tool
  • ASP.NET Core MVC consuming Internal Web API without using Http request
  • In MVC how can I return a IQueryable result and display it in a view using actions
  • Dependency Injection with Unity MVC5 - InjectionFactory Deprecated
  • blazor.server.js file not found
  • Am new to Asp.Net and i just completed my first Application. How can i deploy to IIS server
  • Sum of hours (HH:MM) in Linq
  • How to registr Automapper configuration class in global.asax?
  • Cannot find System.Web.Mvc.UrlHelper.GenerateUrl in .Net Core 3.0
  • Managing user session in Micro frontend
  • How to Call Api Controller from another Api Controller In Same Project
  • App service takes too long to show up after publishing
  • How to get selected value of DropDownList in Post method MVC
  • Cannot implicitly convert type 'System.Collections.Generic.List<string>' to 'System.Collections.Generic.List<Mo
  • Iframe occasionally loses session cookies
  • What JWT Tokens should be stored for use later?
  • ASP.NET MVC : render a string in a view
  • Does EF Core 3.1 support DB First approach?
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk