Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 CustomValidator Control

Author  Topic 

cusoxty
Constraint Violating Yak Guru

271 Posts

Posted - 2004-06-29 : 14:18:59
I am trying to create a custom validation to display an error message if no data is entered into my table 'accounttransfers'.
I am not familiar with the vb.net code, so could someone help me with this this sub to make sure that a record is inserted into the table upon clicking the submit button of my form:

Sub CustomValidation_ServerValidate(s As object, e As ServerValidateEventArgs )

End Sub

MichaelP
Jedi Yak

2489 Posts

Posted - 2004-06-29 : 16:30:27
A custom validator is not how to handle this problem.

A validator would be fired before your INSERT method is called.

What you need to do is this. In the Code behind of the button that they click to insert the record, put a try..catch around that method call. If they get an exception, put the message in a label at the top of the page.

If you need more details on this, feel free to post back here.

Michael

<Yoda>Use the Search page you must. Find the answer you will.</Yoda>
Go to Top of Page

cusoxty
Constraint Violating Yak Guru

271 Posts

Posted - 2004-06-29 : 16:41:39
I'm about to leave work, but will you be here tomorrow to help me with this? I appreciate it!
Go to Top of Page

MichaelP
Jedi Yak

2489 Posts

Posted - 2004-06-29 : 17:06:12
I subscribed to the topic. Any posts you make will send me an e-mail.
I usually don't get to work before about 1PM CST, so it might take a bit of time for me to reply, but I will reply.

Michael

<Yoda>Use the Search page you must. Find the answer you will.</Yoda>
Go to Top of Page

cusoxty
Constraint Violating Yak Guru

271 Posts

Posted - 2004-06-30 : 08:59:26
Ok. I am going to look into this topic a little bit more. So there isn't a way to display a pop up message box? I have to create a label on the page?
Go to Top of Page

MichaelP
Jedi Yak

2489 Posts

Posted - 2004-06-30 : 14:23:57
Well, you could do a pop-up box as well if you like.
Probably what you'd want to do in that case is have a Panel that is set to Visible=False. When you discover the record didn't get inserted, set it to visible, and populate the panel with the javascript needed to do your alert() box. You could also use VBScript to popup that box, but I'd probably go with javascript.

Michael

<Yoda>Use the Search page you must. Find the answer you will.</Yoda>
Go to Top of Page
   

- Advertisement -