下拉列表索引更改时日期选择器不工作 [英] Date picker not working when dropdownlist index change

查看:81
本文介绍了下拉列表索引更改时日期选择器不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的updatepanel中有一个下拉列表和文本框。即AuditName,审核日期。 AuditName下拉列表具有从数据库中检索的值。审核日期是设置日期,这里是使用jquery datepicker。



问题是当页面加载日期选择器工作正常时。但是当我从下拉列表中选择值时,datepicker没有工作(甚至没有显示日期)。



当我先选择日期然后选择文本框值清除的下拉列表。我不知道它为什么会发生..

I have a dropdownlist and textbox in my updatepanel. Namely AuditName, Audit date. The AuditName dropdownlist have the values which are retrieved from database. Audit date is for set the date, here am using jquery datepicker.

The issue is when the page load the date picker is working fine. but when i select the value from dropdown datepicker didnt work(not even display the date).

When i choose the date first then select the dropdown the textbox value is clear. i dont know why its happen..

<script>
     $(function () {
         $('#<%= txtAuditduedate.ClientID %>').datepicker(
             { minDate: 0, changeMonth: true, changeYear: true });
     });
</script>

<asp:UpdatePanel runat="server" ID="upnlAddschedule" UpdateMode="Conditional">
        <ContentTemplate>
            <table cellpadding="5" cellspacing="5" width="100%">                   
                <tr>
                    <td align="right">
                        <asp:Label runat="server" ID="lblAuditlist" Text="Audit Name:/>                            
                    </td>
                    <td align="left">
                        <asp:DropDownList runat="server" ID="ddauditlist" TabIndex="100" AppendDataBoundItems="true" Width="194px"                                AutoPostBack="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"> 
                        </asp:DropDownList>                            
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <asp:Label runat="server" ID="lblDuedate" Text="Audit Due Date:"></asp:Label> 
                    </td>
                    <td align="left">
                        <asp:TextBox runat="server" ID="txtAuditduedate" Width="189px" Font-Bold="False" ReadOnly="true" TabIndex="101" />                            
                    </td>
                </tr>                    
            </table>
        </ContentTemplate>
    </asp:UpdatePanel>



这是我的下拉绑定代码




This is my dropdown bind code

public void FillDropDownList()
    {
        s = WebConfigurationManager.ConnectionStrings["Scon"].ConnectionString;
        con = new SqlConnection(s);
        con.Open();
        cmd = new SqlCommand("select AUDITNAME from MASTER ", con);
        dr = cmd.ExecuteReader();
        while (dr.Read())
        {
            ddauditlist.Items.Add(new ListItem(dr["AUDITNAME"].ToString()));
        }            
        dr.Close();
        con.Close();
    }

推荐答案

(function(){
(function () {


#<%= txtAuditduedate.ClientID%>')。datepicker(
{minDate: 0 ,changeMonth: true ,changeYear: true } );
});
< / script >

< asp:UpdatePanel runat = server ID = upnlAddschedule UpdateMode = 条件 >
< ContentTemplate>
< table cellpadding = 5 cellspacing = 5 width = 100% >
< tr>
< td align = right >
< asp:标签runat = server ID = lblAuditlist Text = 审核名称:/>
< / td>
< td align =
left >
< asp:DropDownList runat =
服务器 ID = ddauditlist TabIndex = 100 AppendDataBoundItems = true Width = 194px AutoPostBack = true OnSelectedIndexChanged = DropDownList1_SelectedIndexChanged >
< / asp:DropDownList>
< / td>
< / tr>
< tr>
< td align =
right >
< asp:标签runat =
服务器 ID = lblDuedate Text =审核到期日: >< / asp:Label>
< / td>
< td align =
left >
< asp:TextBox runat =
server ID = txtAuditduedate Width = 189px Font-Bold = False ReadOnly = true TabIndex = 101 />
< / td>
< / tr>
< / table>
< / ContentTemplate>
< / asp:UpdatePanel>
('#<%= txtAuditduedate.ClientID %>').datepicker( { minDate: 0, changeMonth: true, changeYear: true }); }); </script> <asp:UpdatePanel runat="server" ID="upnlAddschedule" UpdateMode="Conditional"> <ContentTemplate> <table cellpadding="5" cellspacing="5" width="100%"> <tr> <td align="right"> <asp:Label runat="server" ID="lblAuditlist" Text="Audit Name:/> </td> <td align="left"> <asp:DropDownList runat="server" ID="ddauditlist" TabIndex="100" AppendDataBoundItems="true" Width="194px" AutoPostBack="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"> </asp:DropDownList> </td> </tr> <tr> <td align="right"> <asp:Label runat="server" ID="lblDuedate" Text="Audit Due Date:"></asp:Label> </td> <td align="left"> <asp:TextBox runat="server" ID="txtAuditduedate" Width="189px" Font-Bold="False" ReadOnly="true" TabIndex="101" /> </td> </tr> </table> </ContentTemplate> </asp:UpdatePanel>



这是我的下拉绑定代码




This is my dropdown bind code

public void FillDropDownList()
    {
        s = WebConfigurationManager.ConnectionStrings["Scon"].ConnectionString;
        con = new SqlConnection(s);
        con.Open();
        cmd = new SqlCommand("select AUDITNAME from MASTER ", con);
        dr = cmd.ExecuteReader();
        while (dr.Read())
        {
            ddauditlist.Items.Add(new ListItem(dr["AUDITNAME"].ToString()));
        }            
        dr.Close();
        con.Close();
    }


尝试:
<script type="text/javascript">
function pageLoad() {


这篇关于下拉列表索引更改时日期选择器不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆