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
-1
votes
2 answers

ViewBag not displaying data correctly on View

I have a ViewBag in my controller witch contains a List of Linq Items, I created a Foreach Loop in my View to create a table based on the Data in the Viwbag but i get "System.Web.Mvc.SelectListItem" for each item in my loop Controller Viewbag…
Arturo Martinez
  • 389
  • 7
  • 28
-1
votes
1 answer

Pass message B/w Controllers to View Page after logout

I have to send message from controller 1 to controller 3 and finally send to the view. controller 1 public ActionResult controller1() { TempData["data"] = "work finish."; return RedirectToAction("logoff"); } Then in the controller 2 …
anand
  • 1,559
  • 5
  • 21
  • 45
-1
votes
2 answers

Show Json Deserialized data in View-bag using MVC

I generate a JSON file for a city which contains the Interesting Place information of that city. My JSON file look like this- { "Flensburg":[ { "Name": "Flensburg Firth", "Shorttext": "Flensburg Firth or Flensborg Fjord ....", …
user5850934
-1
votes
1 answer

How do I access values of an object created in C# from HTML?

In my MVC controller, I created an 'object' which I'm simplifying as 'student'. I'm using ViewBag to pass it on to my view. In my controller, I have: ViewBag.Student = new { Id = "52", Value = JsonConvert.SerializeObject(new { …
-1
votes
1 answer

Pass data from viewbag to web.config MVC

Looking for advice on passing user credentials from a view bag (that stores session details when the user logs onto my web app) to the web.config where i have a connection string which i would like to pass the user and password to, as seen…
surGe
  • 113
  • 2
  • 2
  • 9
-1
votes
1 answer

how to keep value of viewBag asp.net mvc in view

i have 7 viewBags which holds data in view when the Page Reload (switch to another language ) the ViewBag value became empty how to keep values of these viewBags after Page reload i'm using asp.net mvc 5
-1
votes
2 answers

MVC ViewBag Is Not Appearing In Views At All

Several of my pages on MVC (which had ViewBag.Message by default when setting up MVC) doesn't display at all in the view. Controller: public ActionResult Index() { ViewBag.Test = "Test"; return view(); } Razor View: Index.cshtml

Hello…

Aqib Mehrban
  • 71
  • 2
  • 9
-1
votes
1 answer

Viewbag , Printing data from hashset

i want to print the viewbag recieved from the controller but i cant, my code in the controller is here: var qry = from c in db.Customers join o in db.Orders on id equals o.CustomerID where id == o.CustomerID select new…
-1
votes
1 answer

ViewBag does not show new line

I want to show text on two separate lines for the page header: @section featured {
-1
votes
2 answers

How to use SelectList in View without a model?

I have read many times experts of MVC saying that if I were to use a SelectList, it's best to have a IEnumerable defined in my model. For example, in this question. Consider this simple example: public class Car() { public string…
octref
  • 6,521
  • 7
  • 28
  • 44
-1
votes
1 answer

ViewBag select lists datetime to date

In my controller - ViewBag.DatesEnum = new SelectList(_db.blah.Where(w => w.Active == true).AsEnumerable(), "ID", "Date"); In view - @Html.DropDownListFor(m => m.blahDate, (SelectList)ViewBag.DatesEnum) Ofc it's a datetime value being passed in…
Myzifer
  • 1,116
  • 1
  • 20
  • 56
-1
votes
1 answer

ViewBag and Unknown type using

var Urun = (from u in db.urunlers.Where(x => x.Yayinlama == "1") where u.UrunID == id select new { u.UrunID, UrunAdi= u.UrunAdi, u.UrunAciklama, …
CaKaL
  • 402
  • 1
  • 6
  • 16
-1
votes
2 answers

ViewBag Content not available to Partial Views?

I have a PartialView called TopPanel. This Panel is responsible for displaying error messages generated on any page in my application. To handle this, when any exception occurs on a page, I have it call an "ErrorHandler" action in the TopPanel…
neuDev33
  • 1,573
  • 7
  • 41
  • 54
-2
votes
1 answer

ASP.NET MVC : selected value not working on a List

I have a list of month like this public static class Fecha { public static IEnumerable Meses() { List meses = new List(); meses.Add(new SelectListItem { Text = "Enero",…
-2
votes
1 answer

how to save my dropdown selected values to a textbox...using javascript?

Controller public ActionResult ItemInsert() { ViewBag.Category = new SelectList(db.CategoryMasters.ToList(), "CategoryId", "CategoryName"); ItemViewModel item = new ItemViewModel(); return…
1 2 3
47
48