简体   繁体   English

使用ASP.NET MVC 5动态创建新的网页/视图

[英]Create New Web Pages/Views Dynamically with ASP.NET MVC 5

How would I go about creating new views/web pages dynamically in ASP.NET MVC 5? 我将如何在ASP.NET MVC 5中动态创建新的视图/网页? For example, I'm building an application where users sign in and submit entries, and I want the application to be able to create a new view for each new month. 例如,我正在构建一个应用程序,用户可以在其中登录并提交条目,并且希望该应用程序能够为每个新月创建一个新视图。

I have no idea where to start with this, which part(s) of the MVC I would have to change, and how it would work. 我不知道从哪里开始,我将不得不更改MVC的哪一部分以及如何工作。

Thank you. 谢谢。

You can use model and one view for this and based on the month populate that view. 您可以为此使用模型和一个视图,并基于该视图填充的月份。

Look at the samples for the Model-View-Controller approach 查看模型-视图-控制器方法的样本

You don't need to create any View dynamically, instead you need to create some Views and then render contents of those views dynamically based on Model and other available parameters. 您不需要动态创建任何View ,而是需要创建一些视图,然后根据Model和其他可用参数来动态呈现这些视图的内容。

For example you can show top entries of the month in the main page, and since top entries of the month is a query that its result vary by time, then your main view would be what you need. 例如,您可以在主页上显示该月的前几项,并且由于该月的前几项是一个查询,其结果会随时间变化,因此您将需要使用主视图。

Also you can change the appearance of your Created views based on model too. 您也可以根据模型更改“创建的视图”的外观。 For example you can set background color for your main view based on the season or whatever you want. 例如,您可以根据季节或所需设置主视图的背景颜色。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM