Hi there,
I’m seeing some behavior I can’t explain and which I can fix but I’d prefer to understand what’s happening before circumventing it altogether.
Basically I have a form. You hit submit, it calls if Page.IsValid, and if there is a value not in an acceptable range, the original submit button hides (it’s inside a div that I turned into an htmlgenericcontrol so I could hide the whole div instead of each button inside, there is another button) and along with the out of range warning provide by my custom validator, you get new buttons asking you if you want to submit even though this value is OOR, or do you want to cancel that, and keep editing? (Note that these special OOR buttons are hidden on first page load by setting their enclosing div’s visible to false.) So these buttons are now visible because I have set the enclosing divs visibility to true. There are actually 2 pairs of save/cancel, because you can save your work or you can submit your work as complete, which triggers different validation and DB interaction.
You hit cancel to keep editing work, and the cancel method hides the special buttons’ div, and sets the original buttons’ enclosing div’s visible property to true.
You hit submit again despite still having an OOR value, and it triggers the same loop.
BUT here is the rub, the second time, the special buttons never show up.
I step through the code and discover that:
- on first page load, the visible property of the special buttons in the div are true, as well as the div itself. Then after the line sets that div’s visible to false, I saw the buttons were also visible=false.
- hit submit, the validation calls the toggleOOR, the enclosing div’s visible is set to true, at which point I saw that all of the special buttons were also all visible = true. My code tests that you are in submit mode, and sets the appropriate pair to visible = false.
- you hit cancel, the cancel function sets the specialOOR div visible=false, I find every special button’s visible property is false
- hit submit again, the validation calls the toggleOOR, the enclosing div’s visible property was found by me to be false at this point, then the code sets it to true, I find its property correctly shows true but unlike step 2, this time, each button’s visible property is still false. What gives?
So this is my confusion. Why does it appear that in my first use of the page, the buttons inherit the visibility of the enclosing div…yet not the second?
Now rather than use enclsong divs I can of course just set the buttons’ visibility directly, I was just trying to save some code.
But I’d still like to understand behavior which seems conflicting to me.
If you read all this, thanks.