0

I'm trying to create a custom web control, but I have limited experience with Web Forms. How do I access the text passed in between the open an close tags? The control should work like the this.

Usage

<asp:YesOrNoQuestion>Are you above the age of 18 ? </asp:YerOrNoQuestion>

Control

<tr id="trQ6CA" runat="server" visible="false">
    <td>
        <asp:Label ForeColor="Black" ID="QuestionLabel" runat="server">
          // Question Goes Here
        </asp:Label>
    </td>
    <td>
        <asp:RadioButtonList ID="buttonCollection" runat="server" RepeatDirection="Horizontal">
            <asp:ListItem Value="Y">Yes</asp:ListItem>
            <asp:ListItem Value="N">No</asp:ListItem>
        </asp:RadioButtonList>
    </td>
    <td>
        <asp:RequiredFieldValidator ControlToValidate="buttonCollection" ID="Requiredfieldvalidator" InitialValue="" runat="server" Text="*" ValidationGroup="vgApplication">
            *
        </asp:RequiredFieldValidator>
    </td>
</tr>

Code I'm Replacing

<tr id="trQ6CA" runat="server" visible="false">
    <td valign="top" align="left">
        <asp:Label ID="Label10" runat="server" ForeColor="Black">
            <b>DOES THE PROPOSED INSURED:</b> 
            &nbsp;Have a comprehensive health benefits from an insurance policy, an HMO plan, or employer health benefit plan? <br />
            If No, persons without such comprehensive coverage are not eligible for this insurance policy.
        </asp:Label>
    </td>
    <td valign="top">
        <asp:RadioButtonList ID="rbtQ6S1" runat="server" RepeatDirection="Horizontal">
            <asp:ListItem Value="Y">Yes</asp:ListItem>
            <asp:ListItem Value="N">No</asp:ListItem>
        </asp:RadioButtonList>
    </td>
    <td valign="top">
        <asp:RequiredFieldValidator ID="Requiredfieldvalidator65" runat="server" Text="*" ControlToValidate="rbtQ6S1" InitialValue="" ValidationGroup="vgApplication">
            *
        </asp:RequiredFieldValidator>
    </td>
</tr>
1
  • You can look also Composite Control. I don't like this solution. It's very unreadable and unmanageable only for this three control. The best solution is to use an User Control (ascx) Commented Sep 27, 2017 at 7:10

1 Answer 1

1

You can choose prefix and tag when you register the control: https://msdn.microsoft.com/en-us/library/sbz9etab.aspx

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.