• HOWTO: Add global ajax event handlers with jQuery

    Май 30, 2011

    Task: add global state for selenium tests to wait for when ui is very ajax based. //javascript var _Busy = false; function setBusy(flag) { _Busy = flag; } function isBusy() { return _Busy; } $(document).ajaxStart(function () { setBusy(true); }); $(document).ajaxStop(function () { setBusy(false); }); //C# — selenium wrapper public void WaitForUiReady() { _selenium.WaitForCondition(«selenium.browserbot.getUserWindow().isBusy() == false», […]

  • HOWTO: Required field visualization with Html.LabelFor

    Май 16, 2011

    Based on http://weblogs.asp.net/raduenuca/archive/2011/02/17/asp-net-mvc-display-visual-hints-for-the-required-fields-in-your-model.aspx My solution: namespace WebUI.Extensions { public static class LabelExtensions { public static MvcHtmlString LabelForEx(this HtmlHelper helper, Expression> expression) { var metaData = ModelMetadata.FromLambdaExpression(expression, helper.ViewData); string htmlFieldName = ExpressionHelper.GetExpressionText(expression); string labelText = metaData.DisplayName ?? metaData.PropertyName ?? htmlFieldName.Split(‘.’).Last(); if (String.IsNullOrEmpty(labelText)) return MvcHtmlString.Empty; var label = new TagBuilder(«label»); label.Attributes.Add(«for», helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldId(htmlFieldName)); bool isRequired = metaData.ContainerType.GetProperty(metaData.PropertyName) .GetCustomAttributes(typeof (RequiredAttribute), […]

 
Powered by Wordpress and MySQL. Theme by Shlomi Noach, openark.org