Showing posts with label loads. Show all posts
Showing posts with label loads. Show all posts

Wednesday, March 28, 2012

Viewing Source - Javascript error on missing elements

Hello,

I know this is very likely to be my misunderstanding of how ajax works, but any help would be greatly appreciated.

When my page first loads there is a panel that is not visible, inside the UpdatePanel. After a partial postback this panel becomes visible, but when I 'View Source', the outputted code for the panel does not exists, nor the code for its child controls (even though they show on screen). This means when I try to use client-side code for a control in that panel, eg.

var t = window.document.getElementByID(childID);

it cannot be found as the childID doesn't appear in the source.

Any ideas?

Thanks very much.

Simon

This is actually expected... View/Source in the browser only displays the source that was sent down with the original request.

As for your specific issue, make sure you're using the client ID... a common idiom is: $get('<%= MyControl.ClientID %>'). $get() is a shortcut in ASP.NET AJAX for document.getElementByID().

Saturday, March 24, 2012

watermark disappears after partial postback on another update panel

I have two update panels on page. One of them has an watermark toolkit control which just displays a piece of text in a textbox.

When the page loads the watermark is visible. But if there is a partial postback on the other updatepanel then the watermark disappears.

I am on beta 2 of ajax, and the most recent version of the toolkit.

Is this a known issue, a bug, or are there workarounds?

This scenario should work (and does in at least some circumstances) - please reply with acomplete, self-contained sample page that demonstrates the problem so that we can investigate the specific behavior you're seeing. Thank you!

Way to stop screen jumping when a page loads with an always visible control

I have an always visible control that is set to anchor at the bottom left. The page that it is on is longer than the height of the window so there is a scroll bar.

If I put the image that is always visible in the HTML so that it isn't initally visible on the page (i.e. at the bottom of the page) then the image isn't rendered correctly at the bottom left - it is barely visible and mostly off the screen.

So I have to place the image somewhere in the HTML where it is initially visible on the screen so that it pops down to the bottom left correctly. However, this makes the page jump around when it is first loaded because the image shows where it falls within the HTML and then it jumps down to the bottom left causing the rest of the page to jump up to fill in the void. I have made the image initally have an opacity of 0 so that it isn't visible and then use the animation extender to set the opacity to 100 on the page load. This at least makes it so the user doesn't see where the image initially was but the page still jumps up because the image is still loaded at the top and then moved to the bottom by the always visible control after loading. Unfortunately, if I set the display to none and then use the animation extender to set the display to block it has the same issue as if the image was initially loaded at the bottom of the page, i.e. only part of the image is rendered in the bottom left and the rest falls off the page.

Is there a trick to use to make the page not jump around when using an always visible control?

I'm wondering if setting maintainscrollposition in the page attribute might help?

That was one of the things I had tried but it didn't help. On this particular page I had to turn off MaintainScrollPositionOnPostback because of another bug in the control toolkit. If you have two always visible controls on a page with one set for the bottom left and the other set for the bottom right but do a postback while scrolled part way down the page then when the page reloads the always visible control on the left positions correctly but the one on the right does not position correctly and just remains where it falls inline with the HTML. Once I turned off MaintainScrollPositionOnPostback this issue went away but of course now we lose the functionality of maintaining the scroll position. We'll see what the user's say. If they want the scroll position back we'll have to remove ajax and wait for a later version or perhaps use another vendor's toolkit if they can't fix this one up soon.


Please reply with acomplete, simple, self-contained sample page that demonstrates the problem so that we can investigate the specific behavior you're seeing. Thank you!