Results 1 to 7 of 7

Thread: [RESOLVED] auto post back is clearning my validation errors....

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2006
    Posts
    28

    Resolved [RESOLVED] auto post back is clearning my validation errors....

    Ok i have setup validation using RequiredFieldValidator etc, works great. here's the problem... if you press submit and there are errors, the error messages display, then if the user selects something from my dropdown list which has AutoPostBack on then the errors disappear til u press submit again. how can i fix this? fyi i have autopostback on because i need to check weather a certain item is selected in that dropdownlist to display another textbox.

    Using VS 2003, C# Webform

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: auto post back is clearning my validation errors....

    Did you set the .EnableViewState = True for the validator either in code or via the validators property in the property window?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: auto post back is clearning my validation errors....

    I don't see anything wrong with that behavior, since that was what the ddl was meant for.

    Set the DropDownList's CausesValidation property to True.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    May 2006
    Posts
    28

    Re: auto post back is clearning my validation errors....

    sorry guys i just got back into the office.

    RobDog888: I set the EnableViewState = True for the validator via the validators property in the property window.

    mendhak: i could really care less about whats its doing, and i agree with you, but my boss wants it fixed... on the other hand if a user creates an error it needs to stay on the page until that error is corrected, otherwise if it disappears the user will hit submit again and still have to fix the error b4 continuing, which takes more time for the user.

  5. #5
    Addicted Member MasterBlaster's Avatar
    Join Date
    Jul 2002
    Location
    Seattle
    Posts
    196

    Re: auto post back is clearning my validation errors....

    Of course it is clearing your errors. You are using basically .net generate client side script to validate on the client. That goes away on a postback. You have to re-validate ont the round trip. Each valitator should have a "controlname.validate()" method. You have to call that in the DDL's selectedindex change event.

    if (Myvalidator.Enabled )Myvalidator.Validate();
    "And most of the evils of society can, in fact, be cured through information. We have a society that has been disinformed and based on the disinformation has made irrational choices. And that's what I mean by 'ignorance.' People, who ordinarily might be smart, are deprived of the data by which to make a rational decision, don't have the data to do it."
    Frank Zappa

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: auto post back is clearning my validation errors....

    Did you set the CausesValidation property?

  7. #7

    Thread Starter
    Junior Member
    Join Date
    May 2006
    Posts
    28

    Re: [RESOLVED] auto post back is clearning my validation errors....

    thx MasterBlaster, that was the exact code i needed, it working great now

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width