예제 #1
0
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (output == null)
            {
                throw new ArgumentNullException(nameof(output));
            }

            if (this.Name != null)
            {
                if (this.Name.Metadata == null)
                {
                    throw new ArgumentException(nameof(Name));
                }

                string value = NameAndIdProvider.GetFullHtmlFieldName(ViewContext, this.Name.Name);

                output.Attributes.SetAttribute("name", value);
            }
        }
예제 #2
0
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (output == null)
            {
                throw new ArgumentNullException(nameof(output));
            }

            if (this.Id != null)
            {
                if (this.Id.Metadata == null)
                {
                    throw new ArgumentException(nameof(Id));
                }

                string idFieldName  = NameAndIdProvider.GetFullHtmlFieldName(ViewContext, this.Id.Name);
                string idFieldValue = NameAndIdProvider.CreateSanitizedId(this.ViewContext, idFieldName, _generator.IdAttributeDotReplacement);

                output.Attributes.SetAttribute("id", idFieldValue);
            }
        }