JQuery Datepicker ASP.NET IE7 回发后显示问题
我有一个 ASP.Net 4.0 Web 应用程序,上面有几个 JQuery Datepickers。当页面首次加载并且与其关联的文本框可见时,日期选择器工作正常。 (见附图截图) 然而,当页面首次加载时文本框不可见时,就会出现问题。当发生回发并且文本框在回发后可见时,日期选择器将按其应有的方式显示。然而 CSS 却搞砸了。 (参见附图)这仅适用于 IE 7 - IE8 和 IE9 工作正常。
下面是初始化日期选择器的代码:
function pageLoad() {
$('#<%= dtPolExpDate.ClientID %>').unbind();
$('#<%= dtPolExpDate.ClientID %>').datepicker({
buttonImage: '../../Common/images/calendar.gif',
buttonImageOnly: true,
showOn: 'both',
changeMonth: true,
changeYear: true,
showButtonPanel: true,
closeText: 'Close'
});
当我查看源代码时,CSS 文件已正确加载,JQuery 的 javascript 文件也已正确加载。
我认为这是母版页的问题,所以我创建了一个非常简单的 aspx 页面 - 它也有同样的问题。一旦我单击按钮显示带有日期选择器关联文本框的面板,日期选择器就会混乱。所有页面都有一个嵌套面板,最上面的面板有一个简单的按钮,单击该按钮时会显示带有日期选择器的下部面板。我无法在此处附加该 aspx 文件,但如果需要,我可以拍摄代码的屏幕截图并将其上传到此处。
编辑:附件是所有相关图片:
- 测试代码
- 日期选择器回发之前(在按钮单击之前已经可见)
回发后的日期选择器(在按钮单击后变得可见的不同日期选择器)
请帮忙!
I have an ASP.Net 4.0 web app which has a couple of JQuery Datepickers on it. The datepicker works fine when the page first loads up and if the textbox associated with it is visible. (See attached screenshot)
However the problem comes when the textbox is not visible when the page is first loaded. When a postback occurs and the textbox is visible after the postback, the datepicker shows up as it should. However the CSS is all messed up on it. (see attached screenshot) This is on IE 7 only - IE8 and IE9 work fine.
Here is the code to initialize the datepicker:
function pageLoad() {
$('#<%= dtPolExpDate.ClientID %>').unbind();
$('#<%= dtPolExpDate.ClientID %>').datepicker({
buttonImage: '../../Common/images/calendar.gif',
buttonImageOnly: true,
showOn: 'both',
changeMonth: true,
changeYear: true,
showButtonPanel: true,
closeText: 'Close'
});
When I looked at the source, the CSS files are properly loaded up and so are the javascript files for JQuery.
I thought it was something with the masterpages, so I created a really simple aspx page - it has the same issue too. Once I click the button to show the panel with datepicker associated textbox, the datepicker is messed up. All the page has is a nested panel with the topmost panel having a simple button which when clicked shows the lower panel with the datepicker. I cant attach that aspx file here, but if needed I can take a screen shot of the code and upload it here.
Edit: Attached are all the related images :
- The test code
- The datepicker before postback (which is already visible before button click)
The datepicker after postback (different datepicker which became visible after button click)
Please help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
什么是
pageLoad()
?无论如何,使用
$(document).ready()
例如What is
pageLoad()
?Anyway, use
$(document).ready()
e.g.