【问题标题】:On button click display datepicker after selecting date选择日期后单击按钮显示日期选择器
【发布时间】:2016-11-18 14:30:38
【问题描述】:

如何在单击按钮时选择日期并将该日期传递给 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%;" />

【问题讨论】:

  • 调用调试器是什么意思??
  • 我需要将该日期传递给我的数据库.....
  • 你必须捕获datapicker事件,然后使用ajax连接数据库。
  • 请给我代码......这对我很有帮助......请这是我的要求............
  • 没问题你用的是哪个日期选择器??

标签: javascript c# jquery datepicker


【解决方案1】:

我正在为 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
       }
    });
   }
 });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-07
    • 2017-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-25
    • 2023-03-03
    相关资源
    最近更新 更多