MVC - ViewData

S

shapper

Hello,

In my views I usually have some data that I need to pass from the
controller to the view:

Page Title, Page Keywords, GoogleAnalyticsURL, ...

Then on some views I also have other data to pass. For example, on
Post View I have PostViewData which contains a list of posts and some
statistics.

My idea was to pass to every view two objects: PageViewData and if
necessary PostViewData, FileViewData, or any other view data object.

I believe this is impossible ... So what would be the best way to do
this? Maybe create for all my views the following:

* PageViewData
o PageTitle
o PageKeywords
o GoogleAnalyticsURL

Then when necessary I would do the following:

* PageViewData
o PageTitle
o PageKeywords
o GoogleAnalyticsURL
o Extra

On extra I would add PostViewData ... but I am not sure how can I do
this because Extra can be PostViewData or any other object in case of
other views.

Anyway, could someone give me some suggestion on how to project this?

Thanks,

Miguel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top