Hi,
I have an asp page that renders controls based on a Request parameter. Simplified example:
<% if (Request.QueryString["personType"] == "D") { %>
<asp:TextBox ID="TextBoxName" runat="server" Text='<%# Bind("first_name") %>' />
<asp:TextBox ID="TextBoxSurname" runat="server" Text='<%# Bind("surname") %>' />
<% } else { %>
<asp:TextBox ID="TextBoxName" runat="server" Text='<%# Bind("first_name") %>' />
<% } %>
<asp:RequiredFieldValidator ID="RequiredFieldValidator" runat="server"
ControlToValidate="TextBoxName" ErrorMessage="Please enter an name." />
However, the compiler and runtime are complaining that the TextBoxName is not a unque ID. But surely it is, if the output is conditional and exclusive?
I could rename them TextBoxNameA (if block) and TextBoxNameB (else block), but the odd thing is that the validator still seems to fire on TextBoxNameB, even if the validator is inside the else block and the code runs through the first block at runtime
How can I set the page to render one or the other boxes, without conflicting IDs and conflicting Validators?
Thanks for any help
Ryan