I am wondering if there is an easy way to do the following:
Let's say I have a blog where I need a basic view of the past X number of entries.
For each of these entries, I have a small template for the name, author name, avatar and message body.
It’s simple enough that I can create a template for blog entries, but what if I wanted to use this template for several purposes, introducing another partial view, where do I put the body of the message? There is an easy way to do this in MVC3. Please forgive me if this is simple, maybe I missed the search query :)
Here is an example:
Template for each "record":
@{
ViewBag.Title = "_Entry";
}
<link rel="stylesheet" href="@Url.Content("~/css/post.css")" />
<section id="content" class="body">
<hgroup>
<ol id="posts-list" class="feed">
<li>
<article class="entry">
<header>
<h2 class="entry-title">
<a href="#" rel="bookmark" title="Permalink to this POST TITLE">
</a>
</h2>
</header>
<footer class="post-info">
<abbr class="published" title="2005-10-10T14:07:00-07:00">
</abbr>
<address class="vcard author">
<a class="url fn" href="#">
</a>
</address>
</footer>
</article>
</li>
<li>
<article class="entry">
<footer class="post-info">
<address class="vcard author">
<img src=""></img>
</address>
</footer>
<div class="entry-content">
<p>
</p>
</div>
</article>
</li>
</ol>
</hgroup>
</section>
, ( , ... , , , ( , "" ):
@model MyTemplate.Models.LogOnModel
@{
Page.Title = "Log On";
}
@section HeadContent
{
<link rel="stylesheet" href="@Url.Content("~/css/openid.css")" />
<link rel="stylesheet" href="@Url.Content("~/css/post.css")" />
}
@section ScriptSection
{
<script type="text/javascript" src="@Url.Content("~/js/libs/openid-jquery.js")"></script>
<script type="text/javascript">
$(document).ready(function () {
openid.init('openid_identifier');
});
</script>
<script src="http://ajax.aspnetcdn.com/ajax/mvc/3.0/jquery.validate.unobtrusive.min.js" type="text/javascript"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.8.1/jquery.validate.min.js" type="text/javascript"></script>
}
<section id="content" class="body">
<hgroup>
<ul id="posts-list" class="feed">
<li>
<article class="entry">
<header>
<h2 class="entry-title">
<a href="#" rel="bookmark" title="Permalink to this POST TITLE">
Account Login
</a>
</h2>
<p>
>>
</br>
Please enter your username and password.
<br />
<br />
@Html.ActionLink("Register", "Register") if you don't have an account.
</p>
</header>
</article>
</li>
<li>
<article class="entry">
<footer class="post-info">
<address class="vcard author">
<img src="../img/Hive.png" alt="units" id="gravatar" width="175" height="175" class="imageBorderRadius"></img>
</address>
</footer>
<div class="entry-content">
@Html.ValidationSummary(true)
@using (Html.BeginForm()) {
<div>
<fieldset>
<legend>Account Information</legend>
<div class="editor-label">
@Html.LabelFor(m => m.UserName)
</div>
<div class="editor-field">
@Html.TextBoxFor(m => m.UserName)
@Html.ValidationMessageFor(m => m.UserName)
</div>
<div class="editor-label">
@Html.LabelFor(m => m.Password)
</div>
<div class="editor-field">
@Html.PasswordFor(m => m.Password)
@Html.ValidationMessageFor(m => m.Password)
</div>
<div class="editor-label">
@Html.CheckBoxFor(m => m.RememberMe)
@Html.LabelFor(m => m.RememberMe)
</div>
<p>
<input type="submit" value="Log On" />
</p>
</fieldset>
</div>
}
</div>
</article>
</li>
</ul>
</hgroup>
</section>
@Html.Partial("_OpenId")
.
!
: 2012-02-12
, , MVVM, , , .
Anoop, , , , , MVVM- ASP.NET MVC 3:
, : KsigDo Task Pad - ASP.NET, SignalR, Knockout MVVM EF
<script type="text/html" id="taskTemplate">
<li style="list-style-image: url('/images/task.png')">
<input type="checkbox" data-bind="checked: completed" />
<input class="ui-corner-all" data-bind="value: title, enable: !completed()" />
<input class="ui-button" type="button" href="#" data-bind="click: remove" value="x"></input>
</li>
</script>