ASP.NET MVC3 List all areas - asp.net

I have an ASP.NET MVC3 application in which I am creating multiple areas, is there a way I can find out programmatically the number of areas that are present and their names.
What I want to do it create some partial pages in the different areas and in the main application create a page that will render the partial pages.

Is there a way I can find out programmatically the number of areas that are present and their names
No AFAIK currently there isn't an easy and reliable way to do this. In ASP.NET MVC 4.0 though there will be, I promise :-)
Currently you might need to use reflection and look at all namespaces containing Areas.something and count them. Not very reliable.

Related

Multiple asp.net UI Projects in one solution to share master page

I have searched under different keywords but am not sure if I have found one that is exactly what I'm looking for, even though I have to think it's been asked before. We have say 4 seperate asp.net projects today that we would like to combine into one master solution to share the same master page/ header control. We would have a tab control in the master page, each tab would point to a seperate project. We would need to pass information between projects. An example would be an account list selection from project 1 would need to be retained for project 2 when the user clicks on the project 2 tab. I have to think there is a way to implement this outside of something like iframes. Appreciate any thoughts/insight in advance. Thanks!
Sounds like a good candidate for MVC (model-view-controller). Multiple projects can be loaded into one solution, and shared. If you want to eliminate duplicate views, you could use Razor to render partial or shared views, or a layout page. Ref http://www.asp.net/mvc for more info.
You mentioned iframes. If you're looking for a synchronized solution, you could try multiple views per controller. For an asynchronous solution, AJAX through jQuery etc could work (http://api.jquery.com/category/ajax/).

Dynamically Creating ASP.Net Pages

I am trying to figure out if it is possible to create ASP.Net web pages dynamically. Here is my scenario: I am dynamically creating a huge amount of controls to track data entry that are split up into sections. These sections will play off one another in the sense that if I say I have 5 sections it will create subsections each with the same number of controls and options but divided into groups. This is for tracking the law so it needs to be diverse, dynamic and it obviously has alot of options as the law does. How might one handle something where you have a ton of controls on a page but you want to easily walk the user through the data entry process without confusing them? Our thoughts at this point are as you create the subsections it creates a dynamic webpage that has the subsection controls within it. Or do we need to look to alternative methods - We also thought about hiding the section information doing a display: none with the CSS for each section as you go through the data entry process hiding the controls you are no longer using. how is this possible using ASP.Net with VB? Thanks!
If i understand you want to use client language to manage your controls. May be it's easier to create controls in post back function using vb with viewstate enabled.

Design tips for a search engine in asp.net/asp.net mvc which vaguely resembles a sharepoint view

Guys i am looking for some awesome tips for developing a page which allows users to search for stuff from the db with the view restricted to only certain columns and the data grouped by and sorted by certain columns..
the source in this case is pretty easy to figure out which is a class which retrieves the search results...kapish..
the view in this case is giving me nightmares as i do not want to write that disgusting piece of code which many asp guys are seemingly used to...overriding row created and data bound of gridview etc etc.... i am thinking of simply rendering a html table itself with the necessary preprocessing applied at the datatable level(group by, sortby etc etc on the in memory object retrieved from the paged results)
i need to know if my thought process so far is right or is there a cleaner way of doing the whole thing in asp.net/asp.net mvc etc etc
Congratulations for not wanting to write "disgusting piece of code"... I spent a few years doing just that and the whole overriding row created / bound / etc. thing is a nightmare.
Your source is a class - great. My preferred method would be to go down the jQuery route, use the jqGrid and write an MVC controller that uses your custom class. Or you could dynamically generate your own HTML table but if you have a lot of data I would save yourself the time and explore jqGrid instead. It doesn't have to be MVC - you could embed it into a standard asp.net website, it's just that the MVC approach makes life easier if you have to expand your application to do more things.

Generic ASP.NET MVC models, controllers and views

I am currently evaluating ASP.NET MVC as a possible technology for a web project. As I am a beginner to ASP.NET MVC I need a bit of advice.
We currently have an ASP.NET system that renders grids from data that is retrieved from a database using OLE DB and data tables. The data is rendered on a web page using a grid view that uses the columns from the database. The system is built in a generic way and driven from the database so that we do not have to write a custom page to display and render each table in the database. We effectively have one ASP.NET page that is used to render and edit different tables in the database.
We are looking at rewriting the system using ASP.NET MVC. Is it possible to have generic models, controllers and viewers in ASP.NET MVC that use dictionaries or lists instead of having separate classes for each table in a database?
On the controller side I have seen the following article to convert a data table to an IEnumerable:
Convert DataTable to IEnumerable
However, I am not sure whether the same can be achieved on the model and viewer side.
Is the whole idea of generic models, controllers and views perhaps contrary to the idea of ASP.NET MVC?
Regards
Lucas
First, you don't need custom models for views or controllers if you know you will be using something generic.
Second, you can write editor/display templates that can work on generic data and you can use them in your views.
We are looking at rewriting the system using ASP.NET MVC. Is it possible to have generic models, controllers and viewers in ASP.NET MVC that use dictionaries or lists instead of having separate classes for each table in a database
Generic solutions are very often a excellent recipe for maintenance nightmare. They work well until you have to extend the application. In my experience you do not switch from the generic solution when you want something extra, but do a small workaround. Next time you'll add another small workaround. And after a year you do not want to touch that application again.
If that's not the case for you, congratulations! You can just use a DataTable as your model in the view.

Divide block of asp.net mvc code into different file parts

I have hundred lines of code asp.net in my view, It make me difficult to find what I need it. So do anyone have some idea to divide it into separate files? As I know, in php , have function include().
Take a look at ASP.NET MVC partial views. These let you break down your view into separate reusable components, similar to user controls in ASP.NET WebForms.

Resources