Skip to content

Instantly share code, notes, and snippets.

@chrisortman
Created February 15, 2011 22:30
Show Gist options
  • Save chrisortman/828404 to your computer and use it in GitHub Desktop.
Save chrisortman/828404 to your computer and use it in GitHub Desktop.
Razor view with weird rule
@model InnovativeSystems.OSS.OrderClient.Modules.Order.Web.EditRatePlanModel
@{
ViewBag.Title = "Edit";
}
<script>
$(document).ready(function () {
$('.rate-plan-attributes input:text').editMaskValidate();
});
</script>
<style>
.checkbox-attribute
{
list-style-type:none;
}
</style>
<article id="edit_rate_plan">
<header>
<h1>
@Model.PlanName
</h1>
</header>
<p>
@Model.UserInstructions
</p>
<p>
@Html.ValidationSummary()
</p>
@using(var form = Html.BeginRouteForm("UpdateRatePlanUrl")) {
@Html.HiddenFor(m => m.ServiceId)
<ol class="rate-plan-attributes" data-attributemax="@Model.MaximumQuantity" data-attributemin="@Model.MinimumQuantity">
@foreach(var attrValue in Model.TextValues) {
<li>
<input type="text" name="ratePlanAttributeValue"
value="@attrValue.Value"
data-editormask="@attrValue.EditMask"
data-validateurl="@Url.RouteUrl("ValidateRatePlanAttributeUrl")" />
</li>
}
</ol>
if(Model.CheckValues.Any()) {
<input name="ratePlanAttributeSelection"
type="hidden"
value="THIS_IS_HERE_SO_THAT_THE_INCOMING_FORM_DATA_IS_NOT_NULL" />
<ul>
@foreach(var attrValue in Model.CheckValues) {
<li class="checkbox-attribute">
@if(attrValue.ExclusiveSelection) {
<input name="ratePlanAttributeSelection"
type="radio"
value="@attrValue.Value"
@Html.CheckedIf(attrValue.IsChecked) /> @attrValue.Value
} else {
<input name="ratePlanAttributeSelection"
type="checkbox"
value="@attrValue.Value"
@Html.CheckedIf(attrValue.IsChecked) /> @attrValue.Value
}
</li>
}
</ul>
}
<input type="submit" value="Save Changes" />
}
</article>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment