viewbag Questions

3

Solved

In an ideal 'hello world' one should pass a strongly typed model back to the view. return View(MyModel); If things get sticky, we can create a ViewModel return View(MyViewModel); ex. MyVie...
Dalrymple asked 11/10, 2013 at 14:18

2

Solved

I'm trying to modify this code: http://www.codeproject.com/Articles/260470/PDF-reporting-using-ASP-NET-MVC3 To make it to get the ViewBag data for render the View in the PDF. Basically, I need to ...
Monosome asked 25/6, 2013 at 15:6

3

Solved

I am reading a book on ASP.NET MVC and I'm wondering how the following example works: Example #1 Controller public class MyController : Controller { public ActionResult Index() { ViewBag.MyPr...
Erythrite asked 5/6, 2013 at 20:40

2

Solved

In MVC4, is it possible for ViewBag to ever be null? If so, under what scenarios could it be? If not, how do you know? Specifically, I want to know if it can be null in a view. However, additional...
Jarvisjary asked 30/5, 2013 at 13:23

1

Solved

Ok so I want make a DropDownList from my object list here is my getting object method public List<Category> GetCategoriesList() { BaseShopEntities context = new BaseShopEntities(); List&lt...
Euphony asked 19/5, 2013 at 15:44

1

Solved

I need to send data in the form of a list for two different models in my database to a view in an MVC4 project. Something like this: Controller: public ActionResult Index() { Entities db = new...
Dag asked 1/5, 2013 at 5:46

4

Solved

I guess it's something very straight forward but I can't find out how to do it. In my controller I have: public ViewResult ShowForm() { ViewBag.Title = Resources.ApplicationTitle; ViewBag.Labe...
Adao asked 22/4, 2013 at 8:25

1

Solved

I want to know,What is a best way to create dropdownlists in MVC 4? With ViewBag or another approach?

2

Solved

I have one Viewbag. I have fill that viewbag value from server side in Action result method. I need to access this Viewbag value in Js file. I have access this Viewbag in *.cshl page properly. Here...
Atcliffe asked 26/3, 2013 at 11:43

3

Solved

let's consider two views that use the same layout composed of: A left column containing a "body" (which is filled differently by both views) A right column that displays general information (pas...
Piggott asked 26/6, 2012 at 11:51

1

Solved

I started up a Default MVC 4 project using the ASPX engine (not Razor), and everything works fine. I can use <% Model.Name %> and <% Model.Rating %> for book ratings (instead of...
Lightface asked 30/1, 2013 at 22:30

2

Solved

I am confused with this: I have an action ,say Parent ,and in the corresponding view file ,I have called a child action ,say Child ,both Parent and Child actions are in the same controller. and I ...
Bara asked 12/10, 2011 at 8:20

3

Solved

I have an MVC website with C# code behind. I am using an ActionResult, that returns Json. I am trying to put something in the ViewBag but it doesn't appear to work. The code looks like this - p...
Jornada asked 28/9, 2012 at 14:38

3

Solved

I have a ViewBag.IsLocal set to true in controller. I would like to use jquery to check the ViewBag value and display an alert. Code: if(@ViewBag.IsLocal == true) { alert("yeah"); } I never get...
Lifesaver asked 26/10, 2011 at 15:42

1

Solved

I want to get the data from the ViewBag.mytags to a Javascript array, but I was not able to avhice this $(function () { var sampleTags = new Array(); var array = @Html.Raw(Json.Encode(@ViewBag.m...
Superabundant asked 17/9, 2012 at 6:53

1

Solved

I have the following : ViewBag.SomeEnumerable = new List<string>() { "string1", "string2" }; Now how do I assign ViewBag.SomeEnumerable to an array or some form of enumerable object on th...
Gomes asked 12/9, 2012 at 9:9

1

Solved

So I have the following (pseudo code): string selectedvalud = "C"; List<SelectListItem> list= new List<SelectListItem>(); foreach(var item in mymodelinstance.Codes){ list.Add(new Sele...
Outage asked 24/8, 2012 at 15:40

1

Solved

I just want to ask, is there a way to set up the viewbag value dynamically using jquery? I try this code in my script, $(".btn").on("click",function(){ @ViewBag.Id = $(this).attr("id") }); i do...
Aundrea asked 14/8, 2012 at 8:35

1

Solved

Possible Duplicate: Modifying MVC 3 ViewBag in a partial view does not persist to the _Layout.cshtml I'm trying to set a pageTitle from a PartialView Here is my code: PartialView t...
Pry asked 16/7, 2012 at 18:8

1

Solved

I'm using ViewBag.Message with the same message several times into the methods on the controller. It is possible to declare ViewBag.Message on the top of the class, so can be used in the whole con...
Swish asked 29/3, 2012 at 17:57

3

Solved

Is there a functional difference between ViewState in Webforms and ViewBag in MVC? They seem to be the "same thing". And can be used in the same ways. I ask because MVC promotes the stateless Web a...
Sorrows asked 12/3, 2012 at 2:47

1

Solved

I have a Viewbag that is a list that I am passing from the Controller to the View. The Viewbag is a list of 10 records in my case. Once in the view, if the user clicks on save, I like to pass the c...
Fishbein asked 1/12, 2011 at 22:8

2

Solved

I make heavy use of the ViewBag in my MVC application, is this considered bad practice? I'm unsure as to whether to spend time creating ViewModels (however I thought that was more suited to MVVM ra...
Nielsen asked 30/11, 2011 at 15:9

2

Solved

I am trying to pass a form element into an MVC3 view by using the Viewbag and simply write the HTML to the page ... In controller: ViewBag.myData = "<input type=""hidden"" name=""example"" val...
Cherie asked 13/10, 2011 at 15:22

1

Solved

When will the values of the ViewBag be flushed or cleared ?
Liselisetta asked 28/7, 2011 at 12:9

© 2022 - 2024 — McMap. All rights reserved.