0

I have this repeater where i have added some validation to a textbox. However, the button I wish to use to fire the validation is outside the repeater. Is this possible? If so, I'd rather use server side.

<asp:Repeater ID="rptCart" runat="server" onitemcommand="Cart_ItemCommand" onitemdatabound="Cart_ItemDataBound"> <ItemTemplate> <asp:TextBox ID="cartQty" runat="server" Text='<%#Eval("shoppingCartQty")%>'></asp:TextBox></span> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="oops!" ControlToValidate="cartQty" CssClass="errortxt" Display="Dynamic"></asp:RequiredFieldValidator><asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="oops!" ValidationExpression="^[0-9]*[1-9]+[0-9]*$" CssClass="errortxt" ControlToValidate="cartQty" Display="Dynamic"></asp:RegularExpressionValidator></span> </ItemTemplate> </asp:Repeater> <asp:LinkButton ID="cartRecalcButton" CssClass="cartrecalcbutton" runat="server" ToolTip="recalculate your shopping cart" onclick="cartRecalcButton_Click">&nbsp; </asp:LinkButton> 
1
  • if you want to validate the things in server side, then there is no need to use FieldValidator control. add a span tag with an ID to your markup that runs on server, then change it's InnerHtml in your Button_Click event. Commented Oct 17, 2011 at 16:40

2 Answers 2

2

Yes you can. If you don't want the clientside validation to happen you can set the BaseValidator.EnableClientScript property to false. Validaton controls always performs validation on the server.

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

Comments

1

You shouldn't have any problems using a button outside of the repeater to validate data in the repeater. You can use a ValidationGroup if you want to limit the scope of the validation to the repeater.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.