Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

Using Page.IsValid

Last post 03-21-2008 2:30 PM by katychapman85. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 03-21-2008 9:59 AM

    Using Page.IsValid

    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?

    • Post Points: 10
  • 03-21-2008 1:24 PM In reply to

    • James Crowley
    • Top 10 Contributor
    • Joined on 12-07-2000
    • United Kingdom
    • Guru
    • Points 14,730
    • SystemAdministrator

    Re: Using Page.IsValid

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

    • Post Points: 10
  • 03-21-2008 2:30 PM In reply to

    Re: Using Page.IsValid

    Thanks James, Validation Group was exactly what it needed!

    • Post Points: 5
Page 1 of 1 (3 items)