在Modelpopup文本框中更改Datepicker的位置

时间:2015-07-01 15:14:58

标签: c# asp.net .net datepicker modalpopupextender

我正在开发一个包含AJAX Modelpoup Extenderjquery nepali-datepicker的ASP.Net网络表单。我必须将nepali-datepicker集成到我的第二个modelpopup内的文本框中,即下面的图片中显示蓝色背景。 我面临的问题是我无法将datepicker置于textbox

的底部

基于帖子(How to change the pop-up position of the jQuery DatePicker control)上的答案,我能够在第二个模型弹出窗口前面添加日期选择器。有没有办法可以用来将datepicker实际放到文本框中。

这是我的脚本和样式:

<script type="text/javascript">        
    function pageLoad() {
        $('.nepali-calendar').nepaliDatePicker();
    }

    $(document).ready(function () {
        $('.nepali-calendar').nepaliDatePicker();

    });
</script>    

<style type="text/css">
    div#ndp-nepali-box
    {
        position:absolute;
        z-index: 999999;
    }
</style>

下图显示了它现在的位置。enter image description here

如果我将position用作relative

<style type="text/css">
    div#ndp-nepali-box
    {
        position: relative;
        z-index: 999999;
    }
</style>

看起来像 enter image description here

有没有办法可以将datepicker实际放置到文本框的底部。

2 个答案:

答案 0 :(得分:6)

当您使用jquery UI Datepicker时,它应该具有beforeShow属性并在此属性中更改css,如下所示。

选中此fiddle

$('input.date').datepicker({
beforeShow: function(input, inst) {
 var cal = inst.dpDiv;
 var top  = $(this).offset().top + $(this).outerHeight();
 var left = $(this).offset().left;
 setTimeout(function() {
    cal.css({
        'top' : top,
        'left': left
    });
 }, 10);
}
});

Reference

答案 1 :(得分:0)

尝试相对位置:

<style type="text/css">
    div#ndp-nepali-box
    {
        position: relative;
        z-index: 999999;
    }
</style>

我不知道,什么是div#ndp-nepali-box,但尝试这样做:

<style type="text/css">
    .ui-datepicker
    {
        position: relative;
        z-index: 999999;
    }
</style>

这很重要

相关问题