Questions tagged [viewbag]

ViewBag is a dynamic type object in the ASP.NET MVC framework that can be used to send miscellaneous data from the controller to the view.

ViewBag is a member of the ControllerBase class in the ASP.NET MVC framework. It's a dynamic type object that can be used to send miscellaneous data from the controller to the view. Its type is dynamic.

718 questions
0
votes
1 answer

is passing Viewbag a best approach in asp.net-mvc 3

We've a lots of controllers which return JSON result to the View. The view needs to be dynamic based on user's contract type and user's home location. I'm thinking of passing contract type and other properties using MVC 3.0 ViewBag object. View…
Nil Pun
  • 17,035
  • 39
  • 172
  • 294
0
votes
1 answer

Persisting MVC4 controller data thru multiple post backs

I have a MVC4 controller that calls its view multiple times, each time with a different set of ViewBags. The view renders the contents of a Form based on the absence or presence of those ViewBags via something like this: @using (Html.BeginForm()) { …
davecove
  • 1,001
  • 4
  • 16
  • 36
0
votes
0 answers

ViewBag ViewData and Session values are not accessible from the View

I have tried to use all the above methods to store a value in the controller method, after which I give a call to the partial view. The problem here is the value that I had stored earlier gets flushed. I need to persist that value. What should i…
Soni
  • 3
  • 2
0
votes
1 answer

How to assign value to text input from viewbag when viewbag contains value passed from controller

Im new to ASP.NET MVC3. I tried to pass value from controller to a view and then assign that value to text input inside the view. I tried with viewbag and viewdata. While debugging i could find the value inside viewbag but when my view appers in the…
Mridul Raj
  • 1,001
  • 4
  • 19
  • 46
0
votes
3 answers

Filter Excel Output using MVC 3

I am trying to filter the rows that are sent to a excel file. I have been able to figure out how to export row data to excel, but now I need to send filtered data to an excel sheet since I added a version dropdown. What happens is I select the…
Goldentp
  • 187
  • 1
  • 7
  • 28
0
votes
1 answer

Displaying model assigned name in View Mvc3

This is my View @ using (Html.BeginForm("Display", "Home", @FormMethod.Post)) {
City:America


Pavan
  • 61
  • 9
0
votes
1 answer

Passing controller calculation logic to view with ViewBag

I have a controller that runs some calculation on data, and then I need to return the calculation to a view. I understand that I can accomplish this through the ViewBag, but I would like to know the best practice for doing this. Are these LINQ…
user547794
  • 14,263
  • 36
  • 103
  • 152
0
votes
3 answers

Is there any way to set type of ViewBag item?

Like in topic. It is possible to do it? Or make something to use ViewBag items in place where we need no dynamic item?
Mateusz Rogulski
  • 7,357
  • 7
  • 44
  • 62
0
votes
2 answers

Pass collection via ActionLink

I have a website in ASP.NET MVC3. I want to pass collection to another view. I have this collection in ViewBag. Here is my ActionLink: @Html.ActionLink("Show Report", "Report", new { workList = ViewBag.workReportList }) Controller: public…
Marta
  • 2,857
  • 13
  • 46
  • 67
0
votes
2 answers

Retrieving ActionLink parameter from URL

I have the following: @Html.ActionLink("Customer Number", "Search", new { Search = ViewBag.Search, q = ViewBag.q, sortOrder = ViewBag.CustomerNoSortParm, }) With both viewbag properties coming from the…
stats101
  • 1,837
  • 9
  • 32
  • 50
0
votes
1 answer

Pass ViewBag Values from Razor View to Controller using HTML.Begin

How can I pass a value in ViewBag to controller via HTML.BeginForm()? @using (Html.BeginForm("SaveServiceItemCategory", "Admin", FormMethod.Post, new { Sku = @ViewBag.SkuCategory })) { Service Item Sku :…
Nanu
  • 3,010
  • 10
  • 38
  • 52
0
votes
0 answers

Is viewbag the best option?

I am trying to construct an @Html.ActionLink to return to a previous page but to return to the previous page I need to pass in an id parameter. ShowController/Details list a film defined by a int id, within this list is a link to go and look at the…
Spangle
  • 73
  • 1
  • 7
0
votes
1 answer

ViewBag values accessibility in mvc

The controller in which I define a viewbag value, returns a partial view, which is the last view that is beinng returned. This partial view is rendered to a JQuery dialog. After I close it, I return to the one before, which contains a form. In the…
Tal l
  • 265
  • 1
  • 3
  • 12
0
votes
2 answers

How to pass value from one action to another action having different views in mvc3

Hi I am developing an application in MVC3. and i am stuck at one place. I have 2 fields in my view which are not a part of my class. i am just using them to populate the dropdown The 2 fields are State and District. But i want to show the selected…
user1274646
  • 921
  • 6
  • 21
  • 46
-1
votes
1 answer

How to hide ViewBag in asp.net MVC3 razor View

I am rendering a new view from some view(say mainView) by using Html.ActionLink("","",new{id=packageID}) and my controller action(ActionLink passing control to) look like public ActionResult editChecks(int packageID) {return View();} Now…
RollerCosta
  • 5,020
  • 9
  • 53
  • 71