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

ASP.ET MVC 4 to view data from several tables ViewBag

I need to output information from two tables public class Team { [Key] public int TeamId { get; set; } public int TypeId { get; set; } public string TeamName { get; set; } }public class TeamType { [Key] public int TypeId {…
0
votes
1 answer

How do I to pass value my ViewBag for View in mvc

I have a method which convert my html in a string for export to PDF only I need convert my html (View) to a string in order to export to PDF Code: public string RenderViewToString(Controller controller, string viewName, object viewData) { …
Danielle
  • 139
  • 2
  • 4
  • 19
0
votes
1 answer

Year/Month based Post Archive List With Entity Framework

I want to make a simple Blog Post Archive List like below 2014 January (1) 2013 December (1) November (14) -> Link to search with date October (3) May (5) April (3) I need to send this via ViewBag.Archives. When I perform below SQL in SQL…
Sacmalama
  • 21
  • 5
0
votes
1 answer

mvc3 Viewbag would there be a danger of losing or expiring values

I am using Viewbags as a way to hold dynamic values in a textbox inside my Ajax.forms; would there be a danger of viewbags expiring or losing they're value like a Session variable? This is my simple form @using (Ajax.BeginForm("mydownloads",…
user1591668
  • 2,591
  • 5
  • 41
  • 84
0
votes
1 answer

Javascript 314: Syntax error on @ViewBag assignment

I am passing an array from my MVC5 EF6 controller to the view. When I assign the object to a javascript var, the compiler issues a 314: sytax error. The code works fine, so it is not a big deal however, I cannot publish my webapp because of it. I…
Ungaro
  • 522
  • 6
  • 15
0
votes
1 answer

MVC Viewbag Updated Value Not Showing

I have a ViewBag in my page. When the page is loading, it is showing the ViewBag value. I also have a DropDownList. I want to change the ViewBag value on selection change event and post the value to the Controller via ajax. Controller is also…
0
votes
2 answers

Track last view with C# ASP.NET MVC

I don't have any code to show, because I'm not sure how to approach this. I am sending a user from one view to another where we will be doing CRUD OPERATIONS, I need to have a way of knowing what the last view I came to before the CRUD OPERATION so…
Eric Bishard
  • 5,201
  • 7
  • 51
  • 75
0
votes
1 answer

Viewbag in a DisplayTemplate

How can I pass/send a ViewBag to my DisplayTemplates? I can't use a ViewModel for this so I think on ViewBags... For example: Part of my view: @Html.DisplayFor(model => model.Car) Car.cshtml (displayTemplate): …
Ninita
  • 1,209
  • 2
  • 19
  • 45
0
votes
1 answer

How i can pass value from Controller to View in a Checkbox in MVC

Good afternoon I have the following problem, I need to pass the values ​​that brings a CONTROLLER ViewBag a Checkbox in a view.
Christian
  • 117
  • 1
  • 12
0
votes
2 answers

Can ViewBag be used to pass data from view to the controller or bind to model property

i know that ViewBag and ViewData can be used to pass data and objects from controllers to the corresponding view. Can they be used for vice versa, i.e. to pass data from view to the controller or to bind to model property. I have a file select in…
Why
  • 626
  • 11
  • 29
0
votes
2 answers

ASP.NET MVC 4 ViewBag value incremented only once

Hy! I have a very interesting problem. I have a button and if a user clicks on that button it will reload that page, incrementing the value which is stored in the viewbag and write it on the screen. When the user clicks on the button, the value of…
Gábor Domonkos
  • 1,081
  • 1
  • 17
  • 33
0
votes
3 answers

Generating a Form with ViewBag

I am generating a form list like this foreach (projects p in projects) { ViewBag.ProjectList += @"
@Using(Html.BeginForm())…
0
votes
1 answer

ASP.NET - accessing ViewBag in a View

I have a one page that uses Javascript to load several PartialViews. I am trying to access ViewBag in some Javascript but am having problems. MyView:
The controller…
John 'Mark' Smith
  • 2,564
  • 9
  • 43
  • 69
0
votes
2 answers

Telerik Ajax Binding: Fast Data filtering on previously loaded data

I have a query that takes a while to execute. The data is sent to the grid on the view and some filtering conditions may be sent from the view to the controller. I do not want to re-query the database during each filter. Is there a way to store the…
jpo
  • 3,959
  • 20
  • 59
  • 102
0
votes
1 answer

JqGrid does not load data in mvc

My .cshtml is as follows: