Using Page.IsValid

  • 12 years ago

    Ok on my master page I have a search text box and a button when the button is pressed the SearchButton_Click method checks to see if the page isvalid (i.e. if the user has entered something into the search box) before redirecting the user to the search results page.

    I then have an add product page which uses the master page and has some text boxes for entering the details of the product and a button. When the add product button is pressed the AddButton_Click method checks to see if the page isvalid.

    However it will not add the product as it does not think the page isvalid because nothing has been entered into the search text box. Is there anyway of checking that just the add product text boxes are valid in VB and not the whole page?

  • 12 years ago

    The trick here is to use a ValidationGroup - you can set this property on your RequiredFieldValidator, and on the button you want to trigger validation for those controls. That way, validation will only be checked for the controls you want rather than the whole page :)

  • 12 years ago

    Thanks James, Validation Group was exactly what it needed!

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.” - Rich Cook