ValidationGroup easy explanation

168 views Asked by At

Can someone help me with this line of code and tell me what it is looking for? This chunk of code is associated with a text box control on my page.

ValidationGroup="<%# ((TSAPassenger)((RepeaterItem) Container.Parent.Parent).DataItem).PaxKey %>" runat="server" ErrorMessage="Invalid Contact Name.">
1

There are 1 answers

6
Luke On BEST ANSWER

When a postback occurs (via a button press, autopostback dropdown list, etc), ASP.NET will validate all inputs for the validation group specified on the control that caused the postback.

That line of code is grabbing the 'PaxKey' property of the data item for the repeater item two levels up in the control tree that contains the text box and using it to specify the validation group the textbox belongs to. This is likely there to limit the validation to just the fields for the record you're updating (as opposed to everything on the page).