Search code examples
c#asp.netvalidationrepeater

Validation in repeater causes strange error


I have a repeater in which i have a textbox with a regex validator. The code looks basicly like this:

<asp:Repeater ID="rptr" runat="server">
<ItemTemplate>
        <div>
            <!-- controlls -->
            <asp:TextBox ID="tbText" runat="server" ClientIDMode = "Static" EnableViewState="true" OnTextChanged="tbText_TextChanged"></asp:TextBox>
            <asp:RegularExpressionValidator ID="tbTextValidation" runat="server" Text="*" ToolTip="wrong!" ControlToValidate="tbText" 
                                    SetFocusOnError="false" ValidationExpression="^([a-zA-Z])$">
            </asp:RegularExpressionValidator>
        </div>
</ItemTemplate>
</asp:Repeater>

The problem I have is that when I add a wrong text in the first field of the repeater the error text appears on all textBoxes (even if the rest are correct) If i add a correct text in first field and a wrong text in another field/fields, the error text appears only where it's supposed to(in the wrong fields).

So, my question is, what could cause this?


Solution

  • Please try after removing the ClientIDMode = "Static" from text box of the repeater