问题
I am adding a CalendarExtender to a page, using the default styles. When I click the calendar button to trigger the calendar popup, the calendar displays normally. However, when I scroll down and click the button again, the calendar's position is not where it should be, as seen below.
Why is this occuring and how do I fix it?
EDIT: A bit about the implementation of this page.
The CalendarExtender and TextBox are part of a WebPart added to a SharePoint 2007 Page. I am creating the extender like so:
textBox = new TextBox() { ID = "textBox" };
Controls.Add(textBox);
calendar = new CalendarExtender()
{
ID = "ceStartDate",
TargetControlID = textBox.ID,
PopupPosition = CalendarPosition.Right,
PopupButtonID = image.ID
};
Controls.Add(calendar);
回答1:
What is the DOCTYPE of the page? Also, what browser is it? I have seen this issue on pages with invalid/old DOCTYPEs with IE6-7 in Quirks mode.
In quirks mode, javascript values(like scroll position), can be off, resulting in a bad render. You should ensure you have a valid DOCTYPE that forces IE into standards mode like..
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
回答2:
I came across the same problem today.
Wrap your textbox and calendarExtender in a div with position:relative;
That fixed the problem i was facing, i hope it does the trick for you too
回答3:
Since this is an old post I found trying to solve this situation for myself (unsuccessful following previous answers), I thought my solution to the same issue might be relevant to others.
- We where using an outdated version: 3.0.xxx
- We had to upgrade to latest version: 4.1.xxx
Above versions is the AjaxControlToolkit dll version - not the version you see on NuGet, today the NuGet package ("Ajax Control Toolkit") will be something like 7.xxx.
FYI - My research: I've been using the samples of latest AjaxControlToolkit version to verify if my bug was solved if I upgraded (since I knew exactly how to reproduce my position-issue). At least one of the two sites below should work:
- http://www.asp.net/ajaxlibrary/ajaxcontroltoolkitsamplesite/ (official - slower)
- http://www.ajaxcontroltoolkit.com/ (independent - faster)
来源:https://stackoverflow.com/questions/958555/calendarextender-wrongly-positioned-after-scrolling