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 290725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:01:27+00:00 2026-05-12T06:01:27+00:00

I’m working with a 3rd party system to implement some forms in a website.

  • 0

I’m working with a 3rd party system to implement some forms in a website.

The 3rd party system provides me with XML definitions for these forms.
e.g.

<form>
    <segment>
        <label>The header</label>
        <fields>
            ...
            <field>
                <id>field_Dob</id>
                <type>Date</type>
                <label>Date of Birth</label>
                <required>1</required>
            </field>
            ...
        </fields>
    </segment>
    ...
</form>

I am parsing this XML in a Server Control and programatically generating a tree of controls. The labels of the controls are passed through in the XML.

It is part of our proposal to “inject” little help texts into this form.

Ideally I would like to pass these help texts in from the markup of the top level control so that non-developers (HTML monkies) can change the help texts, and associate them with the field by it’s ID. Something like so

<controls:MyCrazyForm runat="server">
    <helpTexts>
        <helpText for="field_Dob">
Some rambling nonsense to do with the DOB field
        </helpText>
        ...
    </helpTexts>
</controls:MyCrazyForm>

The controls are parsed recursively.

The Form creates a fieldset for each segment, fieldsets create many FieldXXX (where XXX = date, text, combobox etc) depending on the data type.

The FieldXXX types create a div and then several standard .net controls (TextBox, DropDownList, etc) to actually render themselves. It is at this point, within the containing div that I need to output the help text.

My Question

What is the “best” way to get these texts from the top-level form control to these child controls which are 3 or 4 levels deeper in the control tree.

There will only ever be one of these forms on a page.
Should I make the top level form as Singleton and get it like so…?

if(MyCrazyForm.Instance.HelpTexts.ContainsKey("theIdOfTheCurrentField"))
{
    this.HelpText = MyCrazyForm.Instance.HelpTexts["theIdOfTheCurrentField"];
}

Should I pass a reference to the form into every control all the way down the tree (this seems messy)?

Am I miles of target with my architecture of this (although it’s working realyl nicely at the moment) form and should I look at a different method of implementation?

Thanks

  • 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-05-12T06:01:27+00:00Added an answer on May 12, 2026 at 6:01 am

    It may be more complicated at first, but makes it easier to maintain, why not run the xml file through an xsl procesor? The xslt file would assign the helptext nodes of your helptexts file to the corresponding field nodes.

     <?xml version="1.0" encoding="ISO-8859-1"?>
    <form>
        <segment>
            <label>The header</label>
            <fields>
                <field>
                    <id>field_name</id>
                    <type>string</type>
                    <label>Name</label>
                    <required>1</required>
                </field>
                <field>
                    <id>field_Dob</id>
                    <type>Date</type>
                    <label>Date of Birth</label>
                    <required>1</required>
                </field>
            </fields>
        </segment>
    </form>
    

    XSLT file:

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!-- Edited by XMLSpy® -->
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
    
      <xsl:template match="/form/segment/fields/field[id='field_name']">
        <xsl:copy>
          <xsl:element name="helptext">This is a Name helptext.</xsl:element> 
          <xsl:apply-templates/>
        </xsl:copy>
      </xsl:template>
    
      <xsl:template match="/form/segment/fields/field[id='field_Dob']">
        <xsl:copy>
          <xsl:element name="helptext">This is a Date of birth helptext.</xsl:element> 
          <xsl:apply-templates/>
        </xsl:copy>
      </xsl:template>
    
        <xsl:template match="node() | text()">
            <xsl:copy>
                <xsl:copy-of select="@*"/>
                <xsl:apply-templates/>
            </xsl:copy>
        </xsl:template>
    
    </xsl:stylesheet>
    

    yields this:

    <form>
        <segment>
            <label>The header</label>
            <fields>
                <field>
    <helptext>This is a Name helptext.</helptext>
                    <id>field_name</id>
                    <type>string</type>
                    <label>Name</label>
                    <required>1</required>
                </field>
                <field>
    <helptext>This is a Date of birth helptext.</helptext>
                    <id>field_Dob</id>
                    <type>Date</type>
                    <label>Date of Birth</label>
                    <required>1</required>
                </field>
            </fields>
        </segment>
    </form>
    

    This xml file can now be parsed like before, but now you can get the help text at the same time as you are generating the form elements. Your HTML monkies then only need to edit the XSLT file, or you simply include another file :

      <xsl:template match="/form/segment/fields/field[id='field_Dob']">
        <xsl:copy>
          <xsl:element name="helptext">
            <xsl:copy-of select="document('field_Dob.txt')"/> 
          </xsl:element> 
          <xsl:apply-templates/>
        </xsl:copy>
      </xsl:template>
    

    You can try out XSL online here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 135k
  • Answers 135k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Due to the large number of templates instantiated, the error… May 12, 2026 at 7:01 am
  • Editorial Team
    Editorial Team added an answer You asked about best practice, and if you are interested… May 12, 2026 at 7:01 am
  • Editorial Team
    Editorial Team added an answer In the end it appears in your case a singleton… May 12, 2026 at 7:01 am

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.