public void Create_should_return_correct_instance() { IClientSideObjectWriterFactory factory = new ClientSideObjectWriterFactory(); IClientSideObjectWriter writer = factory.Create("foo", "bar", new Mock<TextWriter>().Object); Assert.NotNull(writer); Assert.IsType<ClientSideObjectWriter>(writer); }
public void Create_should_return_correct_instance() { IClientSideObjectWriterFactory factory = new ClientSideObjectWriterFactory(); IClientSideObjectWriter writer = factory.Create("foo", "bar", new Mock <TextWriter>().Object); Assert.NotNull(writer); Assert.IsType <ClientSideObjectWriter>(writer); }
/// <summary> /// Write the initilisation script for the control. /// </summary> /// <param name="writer">The current text writer</param> public override void WriteInitializationScript(System.IO.TextWriter writer) { IClientSideObjectWriter controlWriter = ClientSideObjectWriterFactory.Create(Id, "TreeView", writer); controlWriter.Start(); if (!UseExtendedControlOnly) { controlWriter.Append("persist", "location"); controlWriter.Append("persist", "location"); controlWriter.Append("persist", "location"); } controlWriter.Complete(); base.WriteInitializationScript(writer); }
public static MvcHtmlString DeleteConfirmation <T>(this HtmlHelper <T> helper, string actionName, string buttonsSelector) where T : BaseNopEntityModel { if (String.IsNullOrEmpty(actionName)) { actionName = "Delete"; } var modalId = MvcHtmlString.Create(helper.ViewData.ModelMetadata.ModelType.Name.ToLower() + "-delete-confirmation").ToHtmlString(); //there's an issue in Telerik (ScriptRegistrar.Current implemenation) //it's a little hack to ensure ScriptRegistrar.Current is loaded helper.Telerik(); #region Write click events for button, if supplied if (!string.IsNullOrEmpty(buttonsSelector)) { var textWriter = new StringWriter(); IClientSideObjectWriter objectWriter = new ClientSideObjectWriterFactory().Create(buttonsSelector, "click", textWriter); objectWriter.Start(); textWriter.Write("function(e){e.preventDefault();openModalWindow(\"" + modalId + "\");}"); objectWriter.Complete(); var value = textWriter.ToString(); ScriptRegistrar.Current.OnDocumentReadyStatements.Add(value); } #endregion var deleteConfirmationModel = new DeleteConfirmationModel { Id = helper.ViewData.Model.Id, ControllerName = helper.ViewContext.RouteData.GetRequiredString("controller"), ActionName = actionName }; var window = helper.Telerik().Window().Name(modalId) .Title(EngineContext.Current.Resolve <ILocalizationService>().GetResource("Admin.Common.AreYouSure")) .Modal(true) .Effects(x => x.Toggle()) .Resizable(x => x.Enabled(false)) .Buttons(x => x.Close()) .Visible(false) .Content(helper.Partial("Delete", deleteConfirmationModel).ToHtmlString()).ToHtmlString(); return(MvcHtmlString.Create(window)); }