Skip to content

Custom validator for C# web app

scampercat

Asked Jun 24, 2012, 9:34 AM EDT2 answers
Share
LinkedInX
In a C# 2010 webform application I am working on a couple of custom validators. One of the validators needs to look at a sql server 2008 r2 database to find the lowest and highest value for a create date field.
  My question is how to setup a customer error message that can be generated. Basically I would like the error message to say the create date needs to be within a certain date range. I would do not want to say the create date requested values is not contained in the specific table.
  Thus can you tell me how to setup a custom error message that the custom validator can use?

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Suthish Nair
    0
    string.Format method would be useful in this situation to generate custom strings...
    0
  • 0
    How would you get the string.format message into errormessage listed below: 


    <asp:CustomValidator ID="CustValidatePayDate" CssClass="errorStyle" runat="server" Display="Dynamic" 

    ControlToValidate="" OnServerValidate="ValidatePaymentDate" ErrorMessage="Payment Date invalid" />

     


    </div>
    0