2016-11-18 142 views
0

如何在点击按钮时选择日期并将该日期传递给C#中的调试器?在选择日期后按钮点击显示日期选择器

我的代码工作正常,但我的要求是使用按钮而不是文本框。

首次点击按钮显示日期格式并选择日期。

点击特定日期后应触发功能。

<script> 
    $(function() { 
     $("#txtDate").datepicker(); 
    }); 
</script> 
<asp:TextBox ID="txtDate" runat="server"></asp:TextBox> 
<asp:Button ID="daily" runat="server" Text="GetDailyData" CssClass="btn btn-sm btn-primary" OnClick="submit_Click" style="margin-bottom: 0.4%;" /> 
+0

你的意思是调用调试器? –

+0

我需要将该日期传递给我的数据库..... –

+0

您必须捕捉datapicker事件,然后使用ajax连接数据库。 –

回答

0

我给jQuery UI datepicker的解决方案。

$("#txtDate").datepicker({ 
onSelect: function(dateText, inst) { 
    var date = $(this).val(); //Now you got the date 
    //Connect with database using simple ajax method 
    $.ajax({ 
     url:"http://example.com/your-web-method", 
     type: "POST", 
     data:{"dateValue":date}, 
     success: function(response){ 
      //your actions 
     } 
    }); 
    } 
}); 
相关问题