Last post Mar 27, 2008 01:20 PM by gonzzas
Mar 19, 2008 01:17 PM|gonzzas|LINK
Maybe this is a simple one...
I have a ModalPopupExtender that show a panel when a client validation function returns false (just to display the ValidationSummary in a fancy way).
The problem is that the scroll offset of the page is reset to the top when the ModalPopup shows the panel.
Even if I manually set the offset after the show() method is called, I think that somewhere in the behavior of this extender, the top offset is set to 0 asynchronously. So when i set it to my desired position, the behaviour sets it back to 0.
I can actually see this if I use some "alerts" as breakpoints:
- I click on the submit button (and save the current offset)
- The offset goes to 0 when panel is shown
- The offset goes to my desired position (using the saved offset in a "set offset" function)
Any ideas?! Thanks in advance!
Mar 21, 2008 06:42 PM|gonzzas|LINK
Mar 25, 2008 11:39 AM|Jin-Yu Yin - MSFT|LINK
Thank you for your post!
I suggest you read this ModalPopupExtender panel scroll position
Mar 27, 2008 12:12 PM|gonzzas|LINK
Hi, and thanks for your answer!
It was precisely based on the solution in that thread that I tried to make thing work, but as I said in my original post, something is not working.
For sake of example, here is some sample code of my aspx page:
this three function basically do this:
function val is just a client-side validation function, that shows a modalpopup when some of the custom validators in some validation group are not valid
function saveScroll is called when you click the submit ImageButton (same that causes validation function "val" to be called. "saveScroll" is called before "val")
function setScroll is called after we show the ModalPopup, as you can see in this sample code.
What I get is this:
1. I click on the submit ImageButton (with invalid data on the form)
2. Alert show saying "save 217".
3. We press ok in this alert, the offset is then reset to the top, the modal popup is shown and we get the debug alert saying "set 217"
4. We press ok in this alert, the offset is set correctly to 217 but then is reset to top again... And I don't understand why..
There is no async postback since there are custom validators associated with that ImageButton validation group that are not valid
The ImageButton and the contents to validate are inside an Update Panel (which are in the bottom of the page), but what scrolls up is the offset of the HTML body.
Thanks in advance for any support.
Mar 27, 2008 01:20 PM|gonzzas|LINK
Damn I got it, I was thinking on the async postback issue, and...
I had on the Imagebutton OnClientClick="saveScroll();val('usercontrol');" and changed it to
And it started working...
Then I had another problem... the "return false;" statement can not obviously be there, so the button will never do the async postback.
So I used a global variable named boolReturn that I set to false when the val function shows the popup (when the page is not valid). and did:
The whole thing is not so easy because I have multiple UpdatePanels inside Tabs inside a TabContainer... etc... but for the sake of example, I thinks it's explained and resolved.
Thanks for the answers/comments