viewdata

Equivalent for ViewData from ASP.NET MVC for ASP.NET?

Hi! Is there an equivalent for the ViewData/ TempData object in ASP.NET MVC for ASP.NET? What I wanna do is to keep a Session item only alive for one request. Thanks in advance! Edit: The problem is that I have one view for updating and creating. When the view is in update mode then the session item is filled or it has to be already ...

Why i can't call the Model and ViewData, and Html in the strong typed page?

I created a new strong typed View ,something like this: <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MiniMain.ViewModel.ArticleViewdata>" %> <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> <%Model %> </asp:Content> but when I called...

How do I pass ViewData to a HandleError View?

In my Site.Master file, I have 3 simple ViewData parameters (the only 3 in my entire solution). These ViewData values are critical for every single page in my application. Since these values are used in my Site.Master, I created an abstract SiteController class that overrides the OnActionExecuting method to fill these values for every Ac...

How to populate strongly typed viewdata from a base controller?

All my controllers are based off of a BaseController, to share properties between them and override OnActionExecuting to set some values based on the route. I'm creating a BaseViewData class to do the same for all my view data. At the moment I'm populating the view data like so (C#): var viewData = new BaseViewData { Name = "someN...

Is making a BaseViewData class a property of a BaseController class a bad idea?

Every controller class in my project derive from a base controller class, aptly named BaseController. All view data is contained in a class named BaseViewData (which in the future could become the base controller for more specific view data classes). I made a BaseViewData property on the BaseController since every controller requires a...

passing values to a dropdownlist in an mvc view

I am a newb to MVC programming. I am passing values from other db tables to my edit and create views to populate some dropdownlists. It's working great. I have code like this in my controller for edit and create: var db = new MyProgramDataContext(); Order order = orderRepository.GetOrder(id); ViewData["customer"] = from c in db.custo...

Argh! Why does System.Web.Mvc.HandleErrorInfo get passed to my views?

I'm experiencing a rather frustrating problem. My MVC site runs fine for the most part, but randomly throws an error (which shows a friendly error to the user). When I check the logs, this is what I get: System.InvalidOperationException: The model item passed into the dictionary is of type 'System.Web.Mvc.HandleErrorInfo' but this dicti...

Adding to ViewData[] collection from AuthorizeAttribute Extension

I wrote an extension class to customize my AuthorizeAttribute for my action methods and I'd like to be able to inject messages into my view when a certain condition is met. I"m using the below code to load up a shared view when a user is not authorized but it's not adding my message to my ViewData collection. Any ideas? public overrid...

Combine ViewModel (WPF/Silverlight) and strongly-typed ViewData (ASp.NET MVC)?

Note: I will use the term "ViewModel" for both the ViewModel in WPF/Silverlight and the strongly-typed ViewData in ASP.Net MVC in the following text. I would like to create both ASP.Net MVC and WPF/Silverlight clients for the same project (in other words, against the same DataModel), should I create a common ViewModel project or a separ...

asp.net mvc dropdownlist no ViewData item

i start to study mvc, try to add dropdownlist, make construction <%= Html.DropDownList("ddl") %> but it show error There is no ViewData item of type 'IEnumerable' that has the key 'ddl' why? i use simple code, only pass name parameter, so why the error? ...

ASP.NET MVC Model vs ViewData For Select Lists

I have an ASP.NET MVC application with quite a few drop-down lists and multi-select lists. Essentially, a lot of lists of options. My question is; is it better to pass these lists to the view as part of the Model, or as ViewData? I am currently passing them as ViewData as I don't really need them on the model and they seem potentially ...

How to retrieve value from ViewData when the object is not a string?

Hello, Here's the functionality I'd like to exploit: I've a class myClass and would like to iterate over a collection that contains all the properties of that class. I'd like to send the index of that collection along with the other data so that I can control the each sequence of the iteration. Here's simplified versions of a Action m...

Storing data in HttpContext.Current.Items vs ViewData

When is it appropriate to store data in HttpContext.Current.Items[...] vs storing data in ViewData[...]? I'm trying to figure out the best practices for storing data in this collection and I'm not sure if it's safe to store user-specific data in HttpContext.Current.Items. One use-case is passing down user credits from a base controller...

ViewData.* and TModel in asp.net MVC

After a week of asp.net mvc2, I still haven’t understood the advantages of ViewData.model or rather how I can properly utilize Viewdata. Can some teach me how to use Viewdata properly? Also what’s TModel that’s associated with viewdata? How does one utilize TModel? The viewdata explanation in spark view engine talks about TModel and I c...

asp.net mvc usercontrol viewdata

i have user control, which i render on several views. i want to show viewdata in the usercontrol, but viewdata must be filled in controller method, so i need to fill viewdata on each controller method of each view, where i render usercontrol. is there any simple solutions? ...

When Returning Json results from a Controller

Can ViewData["SOME VALUE"] be returned also? If not, why? ...

There is no ViewData item of type 'IEnumerable<SelectListItem>' that has the key 'xxx'.

There are a couple of posts about this on Stack Overflow but none with an answer that seem to fix the problem in my current situation. I have a page with a table in it, each row has a number of text fields and a dropdown. All the dropdowns need to use the same SelectList data so I have set it up as follows: Controller ViewData["Submar...

ASP MVC ViewData from one view to another (Html.Encode())

Hello all, I have a page with a bunch of labels and checkboxes on it. On this page, the labels need to be easily customizable after the project is deployed. So I made all of the labels in this style: Html.Encode(ViewData["lblText"]) And I added a button on the page called "Edit Button Labels" that will only be seen by admins. When t...

ASP.NET MVC 2 - ViewData empty after POST

I don't really know where to look for an error... the situation: I have an ASPX view which contains a form and a few input's, and when I click the submit button everything is POST'ed to one of my ASP.NET MVC actions. When I set a breakpoint there, it is hit correctly. When I use FireBug to see what is sent to the action, I correctly see...

is there a performance different between passing something into viewdata compared to a view model

in asp.net mvc , if i shove a dictionary or an array of objects in ViewData and read that in my view compared to creating a view model class that has that same data structure, is there a performance difference or other consideration or should i expect the same response time? ...