private IHtmlContent CreateInputElement(TagHelperContext context) { // Create combination of two inputs, one visible for file name, one hidden for file id // Create name input IHtmlContent nameInputContent; if (IsSearchEnabled) { var nameInputTagHelper = new EntitySearchTagHelper(Generator) { Type = typeof(File).Name, Value = (FileProperty.Model as File)?.Name, Class = "file-name-input", FilterName = "category", FilterValue = CategoryString, ViewContext = ViewContext }; var nameInputOutput = CreateTagHelperOutput("search"); nameInputTagHelper.Process(context, nameInputOutput); nameInputContent = nameInputOutput; } else { var nameInput = new TagBuilder("input"); nameInput.Attributes.Add("type", "text"); nameInput.Attributes.Add("class", "form-control file-name-input"); nameInput.Attributes.Add("readonly", "readonly"); nameInput.Attributes.Add("value", (FileProperty.Model as File)?.Name); nameInputContent = nameInput; } // create id input var idInputHelper = new InputTagHelper(Generator) { For = For, ViewContext = ViewContext }; var idInputContent = CreateTagHelperOutput("input"); idInputHelper.Process(context, idInputContent); idInputContent.Attributes.Add("class", "file-id-input"); idInputContent.Attributes.SetAttribute("type", "hidden"); idInputContent.Attributes.Add("value", For.Model?.ToString()); // return input combination return(WrapInDiv(new[] { nameInputContent, idInputContent })); }
private IHtmlContent CreateSearchElement(TagHelperContext context) { var input = new EntitySearchTagHelper(Generator) { Type = Type, Class = Class, Style = Style, ViewContext = ViewContext }; TagHelperOutput inputOutput = CreateTagHelperOutput("search"); input.Process(context, inputOutput); inputOutput.Attributes.Add("class", "form-group"); return(inputOutput); }
private IHtmlContent CreateSearchElement(TagHelperContext context) { string value, name; if (typeof(BaseNamedEntity).IsAssignableFrom(ValueExpression.ModelExplorer.ModelType)) { value = ((BaseNamedEntity)ValueExpression.Model)?.Name; name = ValueExpression.ModelExplorer.Metadata.PropertyName + ".Name"; } else { value = ValueExpression.Model?.ToString(); name = null; } var input = new EntitySearchTagHelper(Generator) { Type = ViewHelpers.GetControllerFor(ValueExpression.ModelExplorer.ModelType), Class = Class, Style = Style, Value = value, Name = name, ViewContext = ViewContext }; if (CurrentOnly) { input.FilterName = "year"; input.FilterValue = ViewContext.ViewBag.SelectedContestYear; } TagHelperOutput inputOutput = CreateTagHelperOutput("search"); input.Process(context, inputOutput); return(inputOutput); }