Using Page.IsValid

  • 11 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?

  • 11 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 :)

  • 11 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.

“The greatest performance improvement of all is when a system goes from not-working to working.” - John Ousterhout