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


Similar Messages:

How To Use Threading To Perform Background Tasks

Jan 29, 2011

In my ASP.NET website, I am having a function which has to be automatically performed once every 2-3 mins on its own, i.e. without user intervention. This function contains database access.

Can I use threading to perform this process in background?

If Yes, How can I use that?

Edit

Also I am not looking for a solution which includes windows service because I am using shared hosting. So I dont have all the rights to access the host computer.

View 5 Replies

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

System.Threading.Tasks - Limit The Number Of Concurrent Tasks?

May 24, 2010

I have just started to look at the new "System.Threading.Tasks" goodness in .Net 4.0, and would like to know if there is any build in support for limiting the number of concurrent tasks that run at once, or if this should be manually handled.

E.G: If I need to call a calculation method 100 times, is there a way to set up 100 Tasks, but have only 5 execute simultaneously? The answer may just be to create 5 tasks, call Task.WaitAny, and create a new Task as each previous one finishes. I just want to make sure I am not missing a trick if there is a better way to do this.

[code]....

View 5 Replies

MVC :: Asynccontroller Multiple Tasks In Parallel Failed Sometime?

Jul 29, 2010

I am experimenting AsyncController feature. What I did is set up two tasks to run in parallel. As in the code below, the problem is that sometime all tasks finished and return successfully, sometime only one task finish and sometime each task finish half of it's work and return. It is weird, what did I do wrong?

[Code]....

View 29 Replies

Perform Multiple Write Operation On A Single File?

Nov 22, 2010

I have a website in asp.net 2.0 which write some thing on a file. But at the same time if another user hit that site it does not work till the first one operation on the file completed after that second one can do operation with the files.

AppConfiguration appConfiguration = new AppConfiguration();
string LogFile =String.Empty;
string sLogFormat =string.Empty;
string sErrorTime =string.Empty;

[Code]....

View 2 Replies

AJAX :: How To Perform Multiple Word Search In Single Textbox

Jun 21, 2013

How to multiple search in single textbox using autocomplete extender.. or may use an other method. 

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

DataSource Controls :: Can't Perform Create / Update Or Delete Operations

May 12, 2010

when i want insert a record i see an error like this

Can't perform Create, Update, or Delete operations on 'Table(MainMenuLink)' because it has no primary key.

with this codes:

MyLinqDataClassesDataContext db = new MyLinqDataClassesDataContext();
MainMenuLink li = new MainMenuLink { Link ="../error/error.aspx", LinkSubject = "subject" };
db.MainMenuLinks.InsertOnSubmit(li);
db.SubmitChanges();
ShowLinks();

what is the problem?

my table have a primary key but i dont know why give an error!!!

View 3 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

Visual Studio :: Create Connection String To Perform Test With Text Book?

Sep 14, 2010

I have installed VS 2010 Ultimate and it came with SQL 2008. what version it is and also how to create a connection in place to keep using the Oreilly examples to hopefully learn how to develop in C#. I have been learning but it is getting more difficult. I try to follow the steps but it just does not make sense. provide some easy steps to check version and connection method to sql using 2010,

I did see a post for sql management(http://www.microsoft.com/downloads/details.aspx FamilyID=08e52ac2-1d62-45f6-9a4a-4b76a8564a2b&displaylang=en). I am going to download to hopefully be able to view the database. We have sql server 2008 at work and I have used the studio management for sql to run queries and would like to do the same with the version that was installed with the installation of 2010 ultimate. I can get the connection to the database so I can start learning how to build a dictionary and list for some queries. My goal is to create a aspx file that will show entries in a database we have at work.

View 2 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 :: 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

MVC :: How To Create Partial Views Using The Razor Engine

Jan 20, 2011

Using the Razor engine how do I create Partial Views. Do I create a normal View and calling the PartialView() in the controller will only output the body content and when calling View() in the controller will output the full page with layout. If not, do I need to create specific Partial Views and then use RenderPartial in the View.

View 6 Replies

DataSource Controls :: Insert A Record Error - Can't Perform Create, Update, Or Delete Operations On 'Table?

May 11, 2010

when i want insert a record i see an error like this Can't perform Create, Update, or Delete operations on 'Table(MainMenuLink)' because it has no primary key. with this codes:

MyLinqDataClassesDataContext db = new MyLinqDataClassesDataContext();
MainMenuLink li = new MainMenuLink { Link = "www.tprogrammer.com", LinkSubject = "subject" };
db.MainMenuLinks.InsertOnSubmit(li); [code]....

View 2 Replies







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