Skip to content

Instantly share code, notes, and snippets.

@Cacodaimon
Created October 2, 2012 20:00
Show Gist options
  • Save Cacodaimon/3822931 to your computer and use it in GitHub Desktop.
Save Cacodaimon/3822931 to your computer and use it in GitHub Desktop.
Used @ cacodaemon.de
<%@ Page Title="" Language="C#" MasterPageFile="/Views/Shared/Site.master" Inherits="System.Web.Mvc.ViewPage<MongoDB.Driver.MongoCursor>" %>
<asp:Content ID="Content" ContentPlaceHolderID="MainContent" runat="server">
<% foreach (Blog.Article article in this.ViewData.Model) { %>
<article>
<h2><a href="<%= Url.Action("ShowArticle", "Blog", new RouteValueDictionary(new { id = article.Id })) %>"><%= article.Title %></a></h2>
<span><%= article.Date %></span>
<p><%= article.Text %></p>
<p></p>
<% if (article.Comments == null) { %>
<p>Comments: <a href="<%= Url.Action("ShowArticle", "Blog", new RouteValueDictionary(new { id = article.Id })) %>#comments">[0]</a></p>
<% } else {%>
<p>Comments: <a href="<%= Url.Action("ShowArticle", "Blog", new RouteValueDictionary(new { id = article.Id })) %>#comments">[<%= article.Comments.Count %>]</a></p>
<% } %>
</article>
<% } %>
</asp:Content>
<%@ Page Title="" Language="C#" MasterPageFile="/Views/Shared/Site.master" Inherits="System.Web.Mvc.ViewPage<Blog.Article>" %>
<asp:Content ID="Content" ContentPlaceHolderID="MainContent" runat="server">
<article>
<h2><%= this.ViewData.Model.Title %></h2>
<span><%= this.ViewData.Model.Date.ToString() %></span>
<p><%= this.ViewData.Model.Text %></p>
<a href="#comments"><h3>Comments</h3></a>
<% foreach (Blog.Comment comment in this.ViewData.Model.Comments) { %>
<aside class="comments">
<p>Autor: <%= comment.Autor %></p>
<span><%= comment.Date %></span>
<p><%= comment.Text %></p>
</aside>
<% }%>
<a href="#post_comment"></a>
<aside class="post_comment">
<% using( Html.BeginForm("AddComment", "Blog")) { %>
<fieldset>
<legend>Post a comment</legend>
<% = Html.Hidden("Id", this.ViewData.Model.Id) %>
<p>Name: </label> <%= Html.TextBox("Autor") %></p>
<p><%= Html.TextArea("Text", "", 5, 100, null) %></p>
<p><input type="submit" value="Submit" /></p>
</fieldset>
<% } %>
</aside>
</article>
</asp:Content>
<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
<!DOCTYPE html>
<html lang="en">
<head runat="server">
<meta charset="utf-8" />
<asp:ContentPlaceHolder ID="head" runat="server">
<title>MVC Test Blog</title>
</asp:ContentPlaceHolder>
</head>
<body>
<header>
<h1>MVC Test Blog</h1>
</header>
<section id="content">
<asp:ContentPlaceHolder ID="MainContent" runat="server">
</asp:ContentPlaceHolder>
</section>
<footer>
Insert a stupid text here...
</footer>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment