Thursday, 15 July 2010

c# - How reliable is the ASP.NET Validator? -



c# - How reliable is the ASP.NET Validator? -

i decided utilize asp.net validator validate dozens of inputs of webform. works fine on client side. mean, i'm totally ok validating inputs without "posting page back" etc.

but when seek utilize validator on code behind, gives me page.isvalid attribute, , confused reliability. here questions couldn't reply myself:

is validator reliable plenty used on client side? (besides disabling javascript, can manipulated?) how validator reach validity info on server side? (is there generated c# validator code somewhere or take info straight client-side?)

here code wrote validate inputs on server side:

foreach (ivalidator ivalidator in page.validators) { if (!ivalidator.isvalid) { homecoming false; } }

but, independent .aspx , .js? can rely on on server side?

you should validate on serverside, done automatically calling page.validate.

from msdn:

this method invoked when user clicks asp.net server command has causesvalidation property set true, default. these include button, imagebutton, , linkbutton web server controls, htmlinputbutton, htmlinputimage, , htmlbutton html server controls, , controls can automatically post server such textbox, checkbox, listcontrol, , bulletedlist controls.

if want forcefulness validation of different validationgroup can phone call manually:

page.validate("myvalidationgroup"); if(page.isvalid) { // ... }

note should check page.isvalid after have called page.validate method, or set causesvalidation property true in onserverclick event handler asp.net server command initiated form processing.

c# javascript .net validation code-behind

No comments:

Post a Comment