How to create view page dynamically in asp.net mvc3

Go To StackoverFlow.com

0

I am working on a classified ads project using mvc. This is my first project in mvc, so I am facing problems to build a small CMS.

In this website scenario is this:

  1. User will create a page and this will be created dynamically and this page will be its home page.
  2. This page contents like (header, menu bar, footer etc.) will be create dynamically.
  3. User can add more pages like about us or contact us. As you would with www.wordpress.com.

I am using tye word dynamically to mean generated by c# or any other method

So I am confused how to create these pages and how to save and manage css, html of these pages.

Please help me with any books or articles (I searched a lot but I did not find a solution)

I don't want to use any CMS Tool (it is a client's requirement)

2012-04-04 19:18
by Stack Me
Is this possible to create multiple views On one action... - Stack Me 2012-04-04 20:20


1

I'm not aware of any books specific on developing a CMS from scratch.

Other than the good books already listed in the answers of Travis J, I can suggest you to look at Umbraco. It's a CMS and you can download the sources.

I strongly suggest you to first read at least one between ProfessionaL ASP.NET MVC 3 and Pro ASP.NET MVC 3 Framework before diving in Umbraco sources.

2012-04-04 20:03
by Iridio
Is this possible to create multiple views On one action... - Stack Me 2012-04-04 20:18
Yes. You can have a method that do some logic and output different views - Iridio 2012-04-04 20:20


1

ORCHARD CMS - it is developed on ASP.NET MVC. May be you can use this CMS as your base and just develope the exact extension you need.

2012-04-04 20:39
by Romias
I hadn't heard of this. Downloaded it to look at the source, as i'm relatively new to mvc - Brian White 2012-04-06 17:54


0

These two books are GREAT for asp.net mvc 3. I highly recommend them and have both of them.

Professional ASP.NET MVC 3

http://www.magazines.com/product/pro-asp-net-mvc-3-framework?affiliate_id=3823&gclid=CJiU_vn6m68CFYYHRQodyz6RbA

Pro ASP.NET MVC 3 Framework

http://www.amazon.com/dp/1118076583/ref=asc_df_11180765831963163?smid=ATVPDKIKX0DER&tag=hyprod-20&linkCode=asn&creative=395093&creativeASIN=1118076583&hvpos=none&hvexid=&hvnetw=g&hvrand=705138720951824289&hvpone=&hvptwo=&hvqmt=

2012-04-04 19:48
by Travis J
I agree that these are good books, but I think that the OP is asking for a specific book on developing a CMS in MVC. And I don't think there are any - Iridio 2012-04-04 19:54
@Iridio - I am not aware of any either, so I offered up the best ones to my knowledge. These will give you the basics to develop your own CMS which is what I had thought the OP was implying - Travis J 2012-04-04 19:57
So any Other helping material for building CM - Stack Me 2012-04-04 19:57
@StackMe - Although not done in asp.net mvc3, you may want to look at the public documentation on joomla, which is an open source php content management system. You could look at the approach they take and try to port some of the functionality - Travis J 2012-04-04 19:58


0

You aren't going to create cshtml pages dynamically. That sounds like a fundamental misconception. I'm new to .net mvc, so my code examples may be off. But I've done many CMSs. One View will be the "render stuff from database" view, I'll call it RenderStuff. You would define a lot of different sections there, so your master layout page can @RenderSection("header"), and your RenderStuff view would do:

@section header {
  //query db for header row based on customer and pageid
  //if found, write out as html
}

You will probably want to set up routing so that you always have two route parameters of customer and page id:

context.MapRoute(
                "Stuff_default",
                "Stuff/{controller}/{action}/{customer}/{pageid}"}
            );

There's a lot more to a CMS.

2012-04-04 20:27
by Brian White
I am also thinking about this concept. but problem is this how manage its body content and css of each page for example if user place image and its some text description then how manage these thin - Stack Me 2012-04-04 21:11
That's what building a CMS is all about. You do not allow infinite flexibility. You allow a few templates because you always end up with just a couple pages pulling data out of the database and plopping it into fields on the page. Check Blogger or WordPress. You could do something in your controller where you query "for customer and page id, what template is this" and then return View("picsLayout") or return View("mainLayout"). Note, ASP.Net MVC can write a CMS, but it has no particular advantage over php or classic ASP for this task - Brian White 2012-04-05 19:55
Ads