Page.IsValid changes to false after button click

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andrew Jocelyn

    #1

    Page.IsValid changes to false after button click

    Hi

    I have couple of dropdown controls each with a requiredfieldva lidator. I
    clear the dropdownlist in the button click event. When the page is rendered
    the dropdown validator already flags it's error message. I checked the
    IsValid property in the prerender event and it says it's false.

    protected void Button_Click(ob ject sender, EventArgs e)
    {
    ddl.ClearSelect ion();
    Trace.Write(Pag e.Validators[0].IsValid.ToStri ng()); // returns True
    }

    protected override void OnPreRender(Eve ntArgs e)
    {
    Trace.Write(Pag e.Validators[0].IsValid.ToStri ng()); // returns False
    base.OnPreRende r(e);
    }

    What could be happening to change the IsValid property to false? I can't see
    anything in my code which would do this. What's the best way to debug this?
    What other checks should I be making?

    Many thanks
    Andrew


  • =?Utf-8?B?YnJ1Y2UgYmFya2Vy?=

    #2
    RE: Page.IsValid changes to false after button click

    Page.IsValid runs the validation logic. so if you clear a selection, then use
    Page.IsValid to run a validation check, it will fail.

    -- bruce (sqlwork.com)


    "Andrew Jocelyn" wrote:
    Hi
    >
    I have couple of dropdown controls each with a requiredfieldva lidator. I
    clear the dropdownlist in the button click event. When the page is rendered
    the dropdown validator already flags it's error message. I checked the
    IsValid property in the prerender event and it says it's false.
    >
    protected void Button_Click(ob ject sender, EventArgs e)
    {
    ddl.ClearSelect ion();
    Trace.Write(Pag e.Validators[0].IsValid.ToStri ng()); // returns True
    }
    >
    protected override void OnPreRender(Eve ntArgs e)
    {
    Trace.Write(Pag e.Validators[0].IsValid.ToStri ng()); // returns False
    base.OnPreRende r(e);
    }
    >
    What could be happening to change the IsValid property to false? I can't see
    anything in my code which would do this. What's the best way to debug this?
    What other checks should I be making?
    >
    Many thanks
    Andrew
    >
    >
    >

    Comment

    Working...