Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

validate text box repeater

Status
Not open for further replies.

ecugrad

MIS
Apr 17, 2001
191
US
Trying to validate a asp.net text box control that is within an asp repeater tag. Text box should only contain numeric values. It will not allow the user to submit the request, but the error message will not display. Code behind is VB.

<asp:Repeater ID="rep_proc" runat="server">
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr align="left">
<td>
<%#DataBinder.Eval(Container.DataItem, "Process")%>
<!--<asp:Literal ID="litname" runat="server"></asp:Literal>-->
</td>
<td>
&nbsp&nbsp&nbsp<asp:TextBox ID="txtItemsProcessed" runat="server" Width="60px" CausesValidation="false"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtItemsProcessed"
Display="None" ValidationExpression="[0-9]{10}" ValidationGroup="numeric">
</asp:RegularExpressionValidator>


</td>
<td>
<asp:Label ID="lblProcID" runat="server" visible="False" class="hideLabel" Text='<%#DataBinder.Eval(Container.DataItem, "ProcessID")%>'></asp:Label>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
 
assuming a button submits the form, the button must have the same validation group "numeric". I would also remove the attribute [tt]Display="None"[/tt] from the RegularExpressionValidator.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
Whats CausesValidation="false" supposed to achieve on the text box by the way?
 
CausesValidation is inherited from a base class. same base class that most WebControls inherit. (in fact it may be a property on the WebControl class, can't remember).

textbox as an autopostback property which will submit the form if the text is changed. this would 1st check validation... I think.

if not, its another example of how convoluted and messy the webforms engine is :)


Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top