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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom Validator

Status
Not open for further replies.

vwhite

Programmer
Oct 4, 2001
87
0
0
AU
Hello all,

I have a Custom Validator in a datagrid to check the validity of a field in a edititemtemplate. However the error message refuses to display. (Even if I deliberately set IsValid to False as shown below)

I have exactly the same type of custom validator in the footer of the datagrid that is used when adding data and it is working perfectly.

Here is a snippet from the datagrid

Code:
<asp:templatecolumn>
					<headertemplate>Unit</headertemplate>
							<headerstyle Font-Bold="true" Width="100"></headerstyle>
							<itemtemplate><%# DataBinder.Eval(Container.DataItem, "UNIT") %></itemtemplate>
							<itemstyle Width="100"></itemstyle>
							<edititemtemplate>
								<asp:dropdownlist runat="server" id="ddlOutputUnit" CssClass="DDL_STYLE" Width="100" DataValueField="UNIT_ID" DataTextField="UNIT" />
								<asp:customvalidator CssClass="ERR_STYLE" id="cvdCompUnitUpdate" runat="server" ErrorMessage="Must use the compulsory unit" ControlToValidate="ddlOutputUnit" Display="Dynamic" OnServerValidate="Test_Valid"/>		
							</edititemtemplate>					
							<footertemplate>
								<asp:dropdownlist runat="server" id="ddlOutputUnit_add" CssClass="DDL_STYLE" Width="100" DataValueField="UNIT_ID" DataTextField="UNIT"/><br>
								<asp:customvalidator CssClass="ERR_STYLE" id="cvdCompUnit" runat="server" ErrorMessage="Must use the compulsory unit" ControlToValidate="ddlOutputUnit_add" Display="Dynamic" OnServerValidate="cvdCompUnit_Validate"/>		
							</footertemplate>

</asp:templatecolumn>

and at the moment I just I have

Code:
Sub Test_Valid(source as object, args as ServerValidateEventArgs)

	args.IsValid = False

End Sub
and I cannot the error message to display

Vicky....

"I used to have a handle on life...then it broke
 
I have the real validation code doing all kinds of stuff which all works fine - but it would never show the error message

So I just put in the test_Valid code and set args.IsValid = False as shown above.

Vicky....

"I used to have a handle on life...then it broke
 
Is it something to do with doing server-side validation? all built in validators work ok. I need to do server side validation as it has to go back to the database to check values.

Vicky....

"I used to have a handle on life...then it broke
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top