Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7885023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:57:17+00:00 2026-06-03T04:57:17+00:00

This is how I’m creating my checkbox: HtmlInputCheckBox checkbox = new HtmlInputCheckBox(); checkbox.ID =

  • 0

This is how I’m creating my checkbox:

HtmlInputCheckBox checkbox = new HtmlInputCheckBox();
checkbox.ID = _Data.ControlID;
checkbox.Attributes.Add("class", "checkbox");
checkbox.Attributes.Add("autocomplete", "off");
sReplacementString = element.RenderToString();

RenderToString is an extension that does this:

public static string RenderToString(this Control control)
{
    StringBuilder sb = new StringBuilder();
    using (StringWriter writer = new StringWriter(sb))
    {
        using (HtmlTextWriter htmlWriter = new HtmlTextWriter(writer))
        {
            control.RenderControl(htmlWriter);
        }
    }
    return sb.ToString();
}

This produces a string with a closing tag on the input, I can see this when debugging.

<input name="ttWBF_1" type="checkbox" id="ttWBF_1" autocomplete="off" class="checkbox" />

It’s then added to the HTML using the Agility Pack as such:

HtmlNode temp = doc.CreateElement("temp");
temp.InnerHtml = sReplacementString;
HtmlNode current = inputNode;

foreach (HtmlNode child in temp.ChildNodes)
{
    inputNode.ParentNode.InsertAfter(child, current);
    current = child;
}
inputNode.ParentNode.RemoveChild(inputNode);

However in the HTML the input tag for the checkbox is missing its self-closing slash and therefore fails WC3 validation.

<input name="ttWBF_1" type="checkbox" id="ttWBF_1" autocomplete="off" class="checkbox">

This happens with my textboxes which are generated in the same way. it looks like they’re getting lost when adding the HTML to the page using the agility pack.

How do I prevent this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T04:57:19+00:00Added an answer on June 3, 2026 at 4:57 am

    In the end it pains me to say that I fell back on processing the HTML with regex to add in the mising self-closing tag. I’d love a better solution as this is hacky and not future proof – it has to be added in for every tag that needs correcting:

    sXHTML = Regex.Replace(sXHTML, "<input(.*?)>", "<input $1 />");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a part of my code used to add new row to a
this my first shot at this awesome new (to me) programmers site, I hope
This is my first attempts at creating a data-mart/warehouse and I am a little
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
This is my first time creating a PHP form that will run a MySQL
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This is my code: OleDbConnection connection = new OleDbConnection( Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\\Offline.accdb;Persist Security Info=False); connection.Open();
This question is for developers who are creating ROMS/custom builds of the Android OS.
This is how a camera is instantiated: var camera = new THREE.PerspectiveCamera( VIEW_ANGLE, ASPECT,
This is really just for my own use: I would like to be able

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.