Server side CustomValidator triggers but does not do anything

M

Mo

Hi,

I using server side customvalidator in a FormVIew insert form. It
triggers and regardless of the fact if args.IsValid is true or false
the data get inserted. am I missing something?

Thanks,
Mo
 
C

Curt_C [MVP]

1) are you sure it's firing?
2) where is the insert/save code firing?
3) do you have a manual Page.Validate and do you have a if(Page.IsValid)
check before insert?
 
M

Mo hariri

Hi,

Thank you for the reply

1) are you sure it's firing?
Yes, I have veried that if goes through "if,then,else"
2) where is the insert/save code firing?
I am using ASP.Net 2.0 and assigned the "insert" command to the
button in the form. It is the standard insert code generated by Visual
Studio
3) do you have a manual Page.Validate and do you have a if(Page.IsValid)
check before insert?
I do not have this. I am not sure where it goes within the standard
generated code.

Any Ideas is greatly appreciated.

Mo
 
M

Mo hariri

I have the following code
void Button2_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
SqlDataSource1.Insert();
Response.Write(" Valid");
}
else
{
Response.Write(" notValid");
}
}
which does the control and will not insert if value is not valid but if
it is valid value then insert nulls in the database. Somewhere I am
missing the binding between the form and the control
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,144
Latest member
KetoBaseReviews
Top