Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I am building a simple cms in asp.net mvc5 , so i finished the News Part , Now i am working with PageConfig Controller , and this is the PageConfig Class, SO in the admin panel or by admin role HOW CAN i add a page dynamically with this page template , can you provide me any source code / tutorial / help how can i achieve that ?!




namespace
{
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;

[Bind(Exclude = "Id")]
public partial class PageConfig
{

[ScaffoldColumn(false)]
public int Id { get; set; }
public string PageId { get; set; }
public string Control { get; set; }
public string Content { get; set; }
public string Placeholder { get; set; }
public Nullable<int> NrOfRecords { get; set; }
}
}




I would be very thankful for any help.

Regards.

What I have tried:

ASP.NET MVC / how to add page dynamically

i described the problem above
Posted
Updated 29-Aug-17 6:54am

Non without Controller and Views (Both is Acquired!)

Before you need to install Entityframework in nuget console.

Setup DbContext (Repository for Database) and Database conectionsTring in web.config.

Right-click Controller Folder in Project Properties, choose "Add Controller" => Empty Templates With Entityframework.

There are two ways to do this.

I recommended you go to acquired the knowledge in verbose on how to working. MVC cant start immediately without stronghold knowledge from starting stage to end.
 
Share this answer
 
If you want to get content from database, you just have to pass string to the View.

Example Controller


Public ActionResult PageConfig()
{
   var html = .... /*Obtain content from database*/;
   return PartialView("PartialViewName",html);
}


Example View
@model String

@Html.Raw(Model)


Hope it helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900