/// <summary> /// Extensions for Entity Framework DbContext /// </summary> public static class DbContextExtensions { /// <summary> /// Gets the edmx connection string from an active DbContext. /// </summary> /// <param name=”context”>The context.</param> /// <returns></returns> public static string GetEdmxConnectionString(this DbContext…Continue Reading →
public ActionResult Foo(){ if (Request.IsAjaxRequest() || ControllerContext.IsChildAction) { return PartialView(); } return View(); }
This is an annoying bug and can catch you out at times. If using the Html.DropDownList() helper and the string id you specify has a property on the model or in the ViewBag that matches, you will use your selection….Continue Reading →
MVC’s separation is fantastic but some times you have areas that need to use a common controller. This is a question I see often asked online. If you have a common model that is used in different areas like a…Continue Reading →
var res = String.Join(“,”, array.Where(s => !string.IsNullOrEmpty(s)));
Just a quick not on how to pass and render HtmlAttributes in a helper: public HtmlString Add(YourObject yourObject, object htmlAttributes = null) { var attributes = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes); //process you markup etc. attributes.ToHtmlAttributes() } public static class RouteValueDictionaryExtensions { public static…Continue Reading →