How can i check if a Validator was raised?

Last post 09-23-2009 7:19 AM by akisasp. 3 replies.

Sort Posts:

  • How can i check if a Validator was raised?

    09-18-2009, 11:24 AM
    • Member
      point Member
    • akisasp
    • Member since 05-19-2009, 7:46 AM
    • Posts 4

    Hello,

    problably not the first to ask this but can't find any info.


    thanks

  • Re: How can i check if a Validator was raised?

    09-18-2009, 1:41 PM
    • Participant
      1,318 point Participant
    • watana72
    • Member since 07-17-2009, 4:37 PM
    • Posts 254

    CodeBehind :

       Page.IsValid

    ASpx : 

    document.getElementById
    ('<%# valSum.ClientID%>').styles.display != "none"

    Cheers,
    Nitin.
  • Re: How can i check if a Validator was raised?

    09-19-2009, 12:09 PM
    Answer
    • Participant
      1,108 point Participant
    • farmas
    • Member since 08-05-2002, 12:19 PM
    • Redmond, WA
    • Posts 246
    • AspNetTeam

    I assume you mean how to write a test with LTAF to verify if a validator is showing or not. The easiest way to do this is to call the IsVisible() method that hangs off the HtmlElement. Here is a sample test that is included in our download that illustrates this:

    // Navigate to the login page
            HtmlPage page = new HtmlPage("Login.aspx");

            // Verify validators are not visible
            Assert.IsFalse(page.Elements.Find("UserNameRequired").IsVisible());
            Assert.IsFalse(page.Elements.Find("PasswordRequired").IsVisible());
            
            // Click the login button (do not wait for postback)
            page.Elements.Find("LoginButton").Click();

            // Verify validators are now visible
            Assert.IsTrue(page.Elements.Find("UserNameRequired").IsVisible());
            Assert.IsTrue(page.Elements.Find("PasswordRequired").IsVisible());


    - Federico

  • Re: How can i check if a Validator was raised?

    09-23-2009, 7:19 AM
    • Member
      point Member
    • akisasp
    • Member since 05-19-2009, 7:46 AM
    • Posts 4

    Thank you both!

Page 1 of 1 (4 items)