JQuery Datepicker ASP.NET IE7 回发后显示问题

发布于 2024-12-10 01:17:33 字数 1165 浏览 0 评论 0原文

我有一个 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 文件,但如果需要,我可以拍摄代码的屏幕截图并将其上传到此处。

编辑:附件是所有相关图片

  1. 测试代码
  2. 日期选择器回发之前(在按钮单击之前已经可见)
  3. 回发后的日期选择器(在按钮单击后变得可见的不同日期选择器)

    请帮忙!

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 :

  1. The test code
  2. The datepicker before postback (which is already visible before button click)
  3. The datepicker after postback (different datepicker which became visible after button click)

    Please help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

も星光 2024-12-17 01:17:33

什么是pageLoad()

无论如何,使用 $(document).ready() 例如

$(document).ready(function(){
    $('#<%= dtPolExpDate.ClientID %>').unbind();
    $('#<%= dtPolExpDate.ClientID %>').datepicker({
        buttonImage: '../../Common/images/calendar.gif', 
        buttonImageOnly: true, 
        showOn: 'both', 
        changeMonth: true, 
        changeYear: true, 
        showButtonPanel: true, 
        closeText: 'Close' 
    });
});

What is pageLoad()?

Anyway, use $(document).ready() e.g.

$(document).ready(function(){
    $('#<%= dtPolExpDate.ClientID %>').unbind();
    $('#<%= dtPolExpDate.ClientID %>').datepicker({
        buttonImage: '../../Common/images/calendar.gif', 
        buttonImageOnly: true, 
        showOn: 'both', 
        changeMonth: true, 
        changeYear: true, 
        showButtonPanel: true, 
        closeText: 'Close' 
    });
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文