How to use Razor Section multiple times in a View & PartialView (merge) without overriding it?

Here’s a solution for that problem. It’s from this blog: http://blog.logrythmik.com/post/A-Script-Block-Templated-Delegate-for-Inline-Scripts-in-Razor-Partials.aspx public static class ViewPageExtensions { private const string SCRIPTBLOCK_BUILDER = “ScriptBlockBuilder”; public static MvcHtmlString ScriptBlock(this WebViewPage webPage, Func<dynamic, HelperResult> template) { if (!webPage.IsAjax) { var scriptBuilder = webPage.Context.Items[SCRIPTBLOCK_BUILDER] as StringBuilder ?? new StringBuilder(); scriptBuilder.Append(template(null).ToHtmlString()); webPage.Context.Items[SCRIPTBLOCK_BUILDER] = scriptBuilder; return new MvcHtmlString(string.Empty); } return new MvcHtmlString(template(null).ToHtmlString()); … Read more

FluentValidation – validating across multiple properties

Finally got it working after I re-read the documentation: “Note that there is an additional overload for Must that also accepts an instance of the parent object being validated.” public class EventModelValidator : AbstractValidator<EventViewModel> { public EventModelValidator() { RuleFor(x => x.StartDate) .NotEmpty().WithMessage(“Date is required!”) .Must(BeAValidDate).WithMessage(“Invalid date”); RuleFor(x => x.StartTime) .NotEmpty().WithMessage(“Start time is required!”) .Must(BeAValidTime).WithMessage(“Invalid Start … Read more

ASP.NET – MVC 3: Localization

Then I found a post that warned about using the App_GlobalResouces and App_LocalResources. (Link) I found that post extremely useful. The method explained there is very clean. Here is a snippet of my newly created index view using that method: @using Resources.Index @{ ViewBag.Title = “Index”; } <h1>@Index.Title</h1> I don’t think there is a definitive … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)