views:

18

answers:

1

I have a view which I want to display different things based on a database field.

  • An authenticated user who has purchased an item should see it in full
  • Authenticated or Anonymous members who have not purchased the item should see a preview

The only data this means changing is the title (prefix the word Preview) and changing the source of the video.

Any suggestions about how to do this and if there is a better approach would be appreciated thanks.


Could I detect the route and base the information from this?

for example: /preview/slug and /purchased/slug?

A: 

Well, it should be nothing more than a few if blocks in your view:

  <asp:Content ContentPlaceHolderID="TitleContent" runat="server">View Video<% if (!Model.IsAuthenticated) { %> Preview<% } %></asp:Content>

You could do something similar for setting the source of the video as well, you just need to create and populate a property like IsAuthenticated (or similar) in your model....

Matthew Abbott
I knew this method was possible just didn't seem like the best method. Still getting used to the pattern :) Thanks.
Daniel Draper