MVC :: Create Multiple Views For Essentially The Same Type Of List?

Jan 31, 2011

If I have a View for 'People' and a View for 'Company' and each has an associated list of 'Orders', should there be a separate view for each? Such as /People/Orders and Company/Orders, or should I simply have a single /Orders views and pass in some parameters?

View 9 Replies


Similar Messages:

MVC :: Create Views That Perform Multiple Tasks?

Oct 3, 2010

This is my first forray into ASP.NET MVC, having been doing WebForms for nearly 6 years now. I've read through various tutorials and guides on getting started with MVC, but I've a few questions about how you're meant to do things:

UserControls for entities

In an application I wrote a few years ago (using WebForms) there were many entities that had an associated postal address (which existed as an instance of an Address class), so I created a UserControl that contained fields for working with addresses. During the page lifecycle I would pass the business object's .Address property to the UserControl for display and for population upon a successful and valid postback. How would I do something like this in MVC? My current project has a similar situation where common sets of fields are repeated throughout the application and all 'map' to the same class.

Modifying the page/view on 'postback'

Say I'm working on a data-entry form for an online B2B ordering system, where the user manually enters order items into a series of textboxes arranged in a table. The system can only provide so-many textboxes at a time (usually 5 or 10). If the user ran out of textboxes they would click an "Add more rows" button that performed a postback that was caught by that button's server-side .Click event handler. The page's class would then add more rows to the page; ASP.NET's stateful nature made this easy to implement. But in MVC there is no ViewState and I haven't found much information about how you'd do this, or anything like this. All of the tutorials and guides assume a form posting is only for data submission.

Multiple tasks per page/form

In a similar vein to the above, how do you create views that perform multiple tasks? In my above example I cited a webform that had two buttons: one to submit the form for actual processing, and another button that just modified the page (by adding more data-entry rows).Given that Controllers' actions are bound to URIs rather than what combination of fields were submitted, does this mean that I would have to interpret the posted data myself and branch based on that?

Componentised self-contained controls (e.g. sidebar forms)

Finally, in many web applications you have the main form in the middle, but also things on the periphary of the page (e.g. a sidebar) that might have their own logic. For example, in one WebForms application I wrote last year there was a 'Quick contact' form in a UserControl located elsewhere on the page. When the user clicked the form's button the UserControl's logic handled the postback details independently of the page containing the UserControl (but there was only one <form> element in the whole rendered page). The user was returned to the page they clicked the button on, with everything in identical state as to how it was before, exccept for the UserControl which reported that the email was sent. Again, MVC's stateless nature would make something like this hard to implement, unless there are some techniques not covered in the tutorials?

View 2 Replies

MVC :: Way To Create A List Type View From A GroupBy Clause

Jan 6, 2010

I can select IQueryable<object-type> data fine from a data repository class and push it into a list type MVC view, but how do I do this and group that data - I don't seem to be able to find any examples on this.

View 9 Replies

MVC: Return Different Views Depending On Object Type?

Jan 3, 2011

my controller, I'm generically deserializing Xml. The object being deserialized to could end up being any number of different types. This, of course, won't be known at compile time. I've created a number of partial views, each of which are strongly typed to a different object that is a possible outcome of the Xml deserializaton.My problem is that I'm struggling with a good way to return the right view. I could always switch on some property in the object, or use a Key/ViewName Dictionary mapping to get the right view name, but I was hoping for something a little more generic than that.Does anyone know of a way that I could implicitly say, "return the view that is typed off of the object I have."?

View 1 Replies

MVC :: Views - Unable To Find Model Type That Is Contained In Module Assembly?

Feb 3, 2011

When i loading modules from different places i injected them to controller factory, but when it is trying to load strongly typed views it can't find model type that is contained in module assembly.I made new ViewEngine and now it looks in right places but it cant load strongly typed views.

So as i understand i need to show the view where to find class model. If you have any other ideas please tel me. And one more i need this problem to be solved for WebFormViewEngine and RazorViewEngine.

View 4 Replies

MVC :: Abstracting List Views Of Different Objects?

Dec 20, 2010

I finding myself repeating myself and the DRY side is nagging me to find an abstraction. I have a number of different entities in an MVC3 Razor web app. They are all business objects and each has a number of different properties that I show to the user in a list. So I have Index views and List partial views for each of these different entities (there are at least 10). I would like to abstract the List partial view so that it's capable of displaying a list of any type of entity. It simply shows them in a table with a column for each property and a row for each entity. My current thinking is that I could receive a list of objects and then use Reflection to see what properties those objects have and use those to make columns. I really wish I could receive a generic List somehow and from my various controllers just pass in an anonymous object (new {Parameter 1=param1, Parameter 2=param2}, etc.) but then I discovered that it's not possible to pass anonymous objects around.

View 1 Replies

C# - How To Create A Generic/parent Type That You Could Send To Methods Without Having To Define An Overload For Each Type

Mar 5, 2011

I'm trying to create a validation layer that will contain methods to validate all my objects (in my Business Objects layer) .. but when I try to reference both the validation and business objects to each other I get a circular dependency error .. so I've decided to create a new layer (BLL) to validate the objects for me and I'll be able to reference both the validation and the object layers.

so I want to build some kind of class/interface -I don't know what fits more- to be like a generic type or a parent type that my method could accept it as a parameter and check for it's Name/ID property. Instead of defining a new method overload for each object type I have
Simplification

View 1 Replies

MVC :: How To Do Multiple Projects With Common Views

Mar 9, 2011

I'm looking at doing a pair of MVC applications. One of the application will be a public website and the other for a POS kiosk. There will be some common views between the two applications. I'm considering having a single Visual Studio solution that will contain the two projects. But, I'm not sure how I can go about sharing the common views between the two projects, without just copy and pasting.

Is there way of doing it? Or should I be looking at using a different approach?

View 3 Replies

VS 2008 Essentially A User Login / Cookies?

Aug 31, 2010

I am making a small silly game but I am not sure of the best way to do it or where to start.Basically I will send a link to the people who are going to playing and on that page they will enter their name. I am then going to get an email with their name in so I can see they have accepted my challenge The game will then redirect to the next page. Thats not a problem.The problem is the game is going to played over a month and each time they visit the game on any page the website needs to know which player is the one who is playing.The other thing Is there is going to be a clue button for each question if they click the clue button for that question They will loose points. Now I want a way of of telling if a user was to display the clue close the website then come back and answer it.Is cookies the best way? Or maybe a cookie for the persons name and a server side file for each player so I have a record of who showed clues for what questions?

View 13 Replies

.net - Override Asp:CreateUserWizard To Essentially Not Require A Password?

Mar 12, 2010

Got this site with UN/PW set via the Createuserwizard control. lient considers PW too large of a barrier to entry and wants to get rid of the password requirement but still have accounts so users simply log back in with emaill address only. I want the quickest fix possible where I use the same provider and control but just use the same static PW for all users on signup, then sort of enter it for them when they "log in" if they return. Works like a cookie basically but has an actual login. Problem is the Createuserwizard.Password property is read only. Can I do AutoGeneratePassword= true and force it to generate the exact same password every time?

View 1 Replies

MVC :: Multiple Views Render As A Single Page?

Mar 20, 2010

I have an MVC 1.0 project and I have created an IView extension so I'm able to render also xslt in addition to normal view form.

the content of each page must be dynamically changes (more or less a CMS), so I write some slots of content (xslt views) and I want to render one or more of this slots into a single page.

It easy to render just one, withe the viewextension or via partial render .. I dont know how to render more than 1. In classic asp the first option should be a virtual include. How can i do that? or smoething similar?

View 3 Replies

Create Dynamic Views In Mvc 2.0?

Mar 17, 2010

How to create dynamic views in asp.net mvc 2.0?

View 1 Replies

How To Create Shared Views In MVC

Jan 20, 2011

In my Views folder I have a several folders such as Category, Origin, Price. They all have a Browse.aspx file and the code in this file displays a table of products. All controllers associated with these folders use the same ViewModel, but in each view I have a repetitive code. The code is:

Folder Category, file browse.aspx
Folder Origin, file browse.aspx
.....

<% foreach ( var p in Model.Products) { %>
<li> <%: p.productname + " " + p.price + " " + p.origin.originname + " " + p.category.categoryname %> </li>
<% } %>

How can I create a shared view and use the shared view in all these views?

View 1 Replies

Security :: User With Multiple Roles And Login Views?

Jul 21, 2010

I have users that belong to more than one role and I have a login view for those roles but I only see the first role's content.

How should I be going about getting to see all content for the roles that user is in? My user logs in and is a member of MACED and ADMIN but only sees the links for MACED

[Code]....

View 3 Replies

Architecture :: Use Separate Pages Or Make One With Multiple Views?

Nov 15, 2010

I'm working on a webforms aspx app (not MVC) and I'm not sure if I should just create separate pages or somehow make multiple views on the same aspx page for the following scenario: Basically, I need to give the user the option to view a set of data a few different ways (essentially different group by's from a data perspective)... the data is always the same, its just a matter of how to arrange on the page...

each way I need to present the data will essentially consist of 2 repeaters, one nested inside the other. The outer repeater will display a nice header section with the nested repeater showing the list of items under that heading. view by book title (title is outer repeater, with the book list being the nested repeater, yes, multiple books with same title for this example - the app has nothing to do with books, this is just to illustrate)

Book Title: A Good Story
Author - Publisher - ISBN
Dan Johnson - Smith Publishing - kjdkjfd99898989
Susan Day - Smith Publishing - aa777fd99ff
Greg Greger - Corp XYZ - amkj897hgrt554

Book Title: Another Good Story
Author - Publisher - ISBN
Frank Franky - Corp XYZ - kj3kjfd9d9980
Jason Cambel - Smith Publishing - 7g7fddddttt
Jill Breker - Smith Publishing - d9ddt523321

Or, view books by publisher (here the publisher would be the outer repeater and the list, with different fields compared to first view, is the nested repeater.

Publisher: Smith Publishing
Title - Author - ISBN
A Good Story - Dan Johnson - kjdkjfd99898989
A Good Story - Susan Day - aa777fd99ff
Another Good Story - Jason Cambel - 7g7fddddttt
Another Good Story - Jill Breker - d9ddt523321

Publisher: Corp XYZ
Title - Author - ISBN
A Good Story - Greg Greger - amkj897hgrt554
Another Good Story - Frank Franky - kj3kjfd9d9980

so what do I do here? Just making separate pages is simple and would work, but is there something else I should be considering? There will be 3 different views, so 3 pages total if I went that route. Something is making me think I should be doing this all within one aspx page? maybe just toggling the visible property of the repeater controls? but then I was thinking each of these repeater controls is databound, and I assume even if they are not visible they still incurred database hits to get the data, right? and that could be bad?

View 4 Replies

MVC :: Checkboxes With 2 Create / Edit Views

Oct 25, 2010

I'm currently writing a game review site in MVC 2. I'm having some problems both figuring out exactly what to use as my view models and how to display checkboxes in my form for a many-to-many relationship. My main models generated by EF4.

The biggest problem at the moment is trying to figure out how to create checkboxes for a game's platforms. There's a many-to-many relationship between games and platforms - each game can be available on a number of platforms (PS3, XBox 360, etc.), and each platform has a library of games. In my Edit view, I need to list all of the platforms and have the ones the current game is listed for checked. I have the following view model:

[Code]....

So, I need to list all of the view model's Platforms while putting a check mark in the GameData's platforms.

View 1 Replies

C# - Create Pages With Different Permission's Views?

Feb 21, 2011

Don't get me wrong, I don't want anyone to write code for me, I just want to know what I'll need to implement. I'll detail what I need: Ex: Facebook page. If I'm at my profile's page I have one type of view, I can edit all my data, see even not set data and add more information. If I'm visiting a friend's page I can only see what he wants me to and interact with his pages as far as he allowed me.

Ex2: One user posted info on some blog. He and all the people with privileges can edit that info, the other can only read and post comments as their permissions allow. Was I clear enough? I wasn't able to find Google references because I don't know the name of this technique and the keywords I typed didn't take me anywhere.

View 1 Replies

MVC :: Create Completely Dynamic Views?

Jul 30, 2010

I want to create a complete dynamic view engine in that absolutely all html content will be loaded from a database. This is so I have a templating engine that is totally customisable. I have something similar in classic asp and the way that works is with fillpoints so you have a master page html which will just be a string when extracted from the database and then content is dynamically added to the string to sections identified by a fill point. So for example I have my master page content loaded into a C# string and I want to load a main view and a partial view onto the page, how would you go about that in MVC? I guess I would have to keep the fill point idea as there is no other way to know where the content will go. I'm just after opinions from the community really on how to go about it.

View 3 Replies

MVC :: Create Partial Views In View?

Feb 22, 2011

I want a view that contains 2 partialviews. 1 partial view should be a create or edit view (of items) and in the second partial view there should be a list with the items that are created (and which can be edited). When an item in the list is selected for editing the 1st partial view should show the edit view with the item to be edited.

After saving the data, the create view should be shown in the 1st partial view again. When the view comes up for the first time the 1st partialview should contain the create view. In normal ASP.net I would do this with a formview (with insert and edit mode based on the itemselected in the gridview) and a gridview (and of course everything in an AJAX update panel).

View 2 Replies

Web Forms :: How To Create An Instance Of A Type From Type

Feb 1, 2010

How would I create an instance of a type if all I have is the type in string form?

[Code]....

Now if I wanted to create and instance of myType how would I do that ?

View 1 Replies

JQuery ::create A 'hyperlink' Type And A 'pdf' Type?

Feb 28, 2011

I am struggling to find relevant documentation on this, what I basically want to do is to create a 'hyperlink' type and a 'pdf' type that I can put into my XML file and use to link to a webpage or a PDF, with the relevant icon.

Here is my JQuery :

[Code]....

And my XML :

[Code]....

View 5 Replies

Web Forms :: Using Loop To Send Multiple Emails With Alternate Views

Feb 1, 2010

[Code]....

Using a loop to send multiple e-mails with alternate views

View 4 Replies

MVC :: Achieve A Reusable Area In Multiple Views (navigation Menu)?

Sep 16, 2010

I want to build my navigation so I can use it on multiple views. How do I do this? Nested views? Whats the best practice and show me a quick example?

View 1 Replies

MVC :: Posting Form Data From Multiple Partial Views On The Same Page?

Feb 8, 2011

I have view that dynamically adds multiple partial views with a foreach statement with the standard <%Html.RenderPartial("partialName", model); %> . The partial view control has just a label and textbox control. When I view the source html generated it correctly has a single form control around all the multiple labels and textboxes. My single submit button, inside the form though does not send any of the form data back to the controller though when using FormCollection.

View 1 Replies

MVC :: Handle Strongly Typed Views If Have Multiple Objects/models?

Mar 16, 2011

<p>Hi</p> <p>I'm a newbie in MVC but a veteran web forms developer. I really like the idea of strongly typed views but what if I have multiple objects to pass to my razor view. Would I then NOT use strongly typed views and just use the ViewBag?</p>

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved