viewbag Questions
9
Solved
Controller:
public ActionResult Filter()
{
ViewBag.Accounts = BusinessLayer.AccountManager.Instance.getUserAccounts(HttpContext.User.Identity.Name);
return View();
}
View:
<td>Account: ...
Sanderlin asked 16/5, 2013 at 18:37
6
I have a really simple ViewBag.Title. Like this:
@{
ViewBag.Title = "My Title";
ViewBag.MiniTitle = "Sub - Title";
}
Which is being parsed on _Layout.cshtml, on the
<title>@ViewBag.Tit...
Nibble asked 31/12, 2013 at 19:28
1
This is my main view named _ShowSingleProduct.cshtml:
<div class="col-md-7">
<!-- Review-->
<div class="product-review pb-4 mb-4 border-bottom">
//*Here I'm...
Drandell asked 12/3, 2022 at 1:48
11
Solved
For the ViewBag, I heard it was a no-no to use.
I would assume have the content from the ViewBag should be incorporated into a view model?
Question:
Is my assumption above the best practi...
Deemster asked 29/6, 2012 at 12:45
7
Solved
My attempted methods.
Looking at the JS via browser, the @ViewBag.CC is just blank... (missing)
var c = "#" + "@ViewBag.CC";
var d = $("#" + "@ViewBag.CC").value;
var e = $("#" + "@ViewBag.CC"...
Newcastle asked 4/4, 2012 at 9:2
3
Solved
I have to move my UI page from a .cshtml file to an .aspx file. Now I'm having a couple of compiling errors.
First is that 'ViewBag' does not exist in the current context. Can I not use it in .asp...
Tartaric asked 1/3, 2016 at 0:17
6
Solved
Consider this simple controller:
Porduct product = new Product(){
// Creating a product object;
};
try
{
productManager.SaveProduct(product);
return RedirectToAction("List");
}
catch (Exception...
Beliabelial asked 27/12, 2011 at 3:39
17
Solved
I saw the ViewBag in MVC 3. How's that different than ViewData in MVC 2?
Dubiety asked 16/1, 2011 at 12:49
4
Solved
I have an MVC3 C#.Net web app. I am looping through a DataTable. Some rows are importing OK, some are not. I am wanting to send a list of errors back to the view in a list format. I am assigning th...
Bolme asked 8/2, 2012 at 17:30
2
Solved
This seems so simple it's embarrassing. However, the first question is when passing a value from the new ViewBag in MVC 3.0 (Razor) into a JavaScript block, is this the correct way to do it? And mo...
Lapp asked 21/4, 2011 at 20:43
8
Solved
I have a controller calling a view. In the view there is a PartialView called be @Html.Partial("ViewName", model). This works fine.
But in the controller I wish to put something in the viewbag wha...
Reverberate asked 20/4, 2011 at 11:53
4
Solved
I have this Index action:
public ActionResult Index()
{
var repo = (YammerClient) TempData["Repo"];
var msgCol = repo.GetMessages();
ViewBag.User = repo.GetUserInfo();
return View(msgCol.me...
Thracian asked 26/3, 2014 at 16:18
9
Solved
Hi i need to show a list of data using viewbag.but i am not able to do it.
Please Help me..
I tried this thing:
ICollection<Learner> list = new HobbyHomeService().FetchLearner();
ICollecti...
Hertha asked 9/5, 2012 at 18:18
4
Solved
The goal is to get the data from the ViewBag.Array to a Javascript array. The data is calculated in the controller so I cannot fetch it straight from the database. I need the data to draw a chart w...
Jews asked 29/4, 2011 at 9:50
7
Solved
There is, for example, the ViewBag property of ControllerBase class and we can dynamically get/set values and add any number of additional fields or properties to this object, which is cool. I want...
6
Solved
I know this seems pretty basic, and it should be, but I can't find out where I am going wrong. (I hve read other articles with similar titles on SO, and other resources on the web but still cant fi...
Neologize asked 2/7, 2012 at 15:26
16
Solved
I am trying to use ViewBag in my application, I have all of the recent dlls, the latest version of MVC 3, but yet I am still getting the Error:
"The name 'ViewBag' does not exist in the current ...
Kyliekylila asked 10/2, 2011 at 16:56
3
Solved
When I try to assign a value to the ViewBag I get the following error:
Cannot apply indexing with [] to an expression of type 'System.Dynamic.DynamicObject'
My code is as follows:
public Act...
Aboard asked 20/12, 2013 at 20:40
5
I am trying to receive bool values from ViewBag.
But the issue is that to receive value I am using:
var test = '@ViewBag.Test'
In this way value will be 'True' or 'False' (string). Of cource I ...
4
Solved
This is probably a silly question, but I am trying to stuff an anonymous object in ViewBag like so:
ViewBag.Stuff = new { Name = "Test", Email = "[email protected]" };
and access it from a...
Betoken asked 23/1, 2012 at 23:20
5
Solved
Imagine a view bag called
ViewBag.Modes
this contains the following:
Simple
Advanced
Manual
Complete
How can I access the viewbag by index like you would in an array?
e.g Simple is at inde...
Matsumoto asked 24/9, 2014 at 13:37
3
Solved
I'm using razor syntax and I want to check to see if certain ViewBag values are set before I spit out the html. If a value is set then I want to write it out. If not I want it to do nothing.
@if (...
Sungkiang asked 4/8, 2011 at 3:20
4
Solved
Ey!
How I could refresh a Partial View with data out of the Model?
First time, when the page loads it's working properly, but not when I call it from the Action.
The structure I've created looks li...
Unhallowed asked 15/8, 2013 at 14:23
7
Solved
How does the ASP.NET MVC's ViewBag work? MSDN says it is just an Object, which intrigues me, how does "Magic" properties such as ViewBag.Foo and magic strings ViewBag["Hello"] actually work?
Also,...
Expressivity asked 15/2, 2013 at 13:39
1
Solved
During writing unit tests for ASP.NET Core application I realized that the ViewData is accessable from ViewResult but ViewBag is not.
My HomeController:
public class HomeController : Controller
{...
Koehler asked 3/8, 2017 at 1:19
1 Next >
© 2022 - 2024 — McMap. All rights reserved.