Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

Validate multiple fields against db table

$
0
0

Hi all,

I am working on my first web application and now I have run in to a problem with a custom validator I am trying to use. The thing is that I have to check three input fields against a database table to decide if this is a unique combination that can be inserted or if it already exists. I think I understand how to write the validator on the form page and I know how to connect to the database to check the table. The problem right now is that I can't get hold of the fields to validate in my function. Probably easy to solve but like I said...I'm a noob ;)

My custom validator:

<asp:CustomValidator ID="CustValUniqueKeyNbr" runat="server"
Display="Dynamic" OnServerValidate="CustValUniqueKeyNbr_ServerValidate"
ErrorMessage="There is already an active entry with this number and keyword"></asp:CustomValidator>

On the code page:

Protected Sub CustValUniqueKeyNbr_ServerValidate(ByVal sender As Object, ByVal args As ServerValidateEventArgs)

'Here I would like to get the values from the textboxes
Dim num As String = NumTextBox.Value
Dim key As String = KeyTextBox.Value
Dim todate As Date = ToDateTextBox.Value

'Connect to database and check input

Any help would be greatly appreciated!


Viewing all articles
Browse latest Browse all 23244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>