Antarr Byrd
Antarr Byrd

Reputation: 26159

Creating Custom Web Control

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>

Upvotes: 0

Views: 360

Answers (1)

Emanuele
Emanuele

Reputation: 664

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

Upvotes: 1

Related Questions