Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap Datepicker with Asp.Net Textbox

Maybe it will be a silly question but I couldn't handle my problem. I checked all the questions and answers on here but I didn't find any clue. Anyway, I want to use the bootstrap datepicker with asp.net textbox. When I use it with input without the runat="server" tag, I see that the datepicker shows up, but when I try to use it with textbox with the runat="server" tag, the datepicker is not showing. Any idea on how to solve this issue?

<asp:TextBox ID="DateTextbox" runat="server" CssClass="m-wrap span12 date form_datetime"></asp:TextBox>

    <script type="text/javascript">
    $(document).ready(function () {
        var dp = $("#<%=DateTextbox.ClientID%>");
            dp.datepicker({
            changeMonth: true,
            changeYear: true,
            format: "dd.mm.yyyy",
            language: "tr"
        });
    });
    </script>

Thanks for your answers.

like image 329
Erdinç Avatar asked Mar 22 '23 18:03

Erdinç


2 Answers

thanks for your answers. i did a lil change on my code its working now. i am posting for further use.

 <script type="text/javascript">
    $(document).ready(function () {
        var dp = $('#<%=DateTextbox.ClientID%>');
        dp.datepicker({
            changeMonth: true,
            changeYear: true,
            format: "dd.mm.yyyy",
            language: "tr"
        }).on('changeDate', function (ev) {
            $(this).blur();
            $(this).datepicker('hide');
        });
});
</script>

but i dont understand whats make the diffrence between (") and (') ?

like image 59
Erdinç Avatar answered Apr 06 '23 18:04

Erdinç


Try this

<asp:TextBox ID="DateTextbox" ClientIDMode="Static" runat="server" CssClass="m-wrap span12 date form_datetime"></asp:TextBox>


 <script type="text/javascript">
    $(document).ready(function () {
        var dp = $("#DateTextbox");
            dp.datepicker({
            changeMonth: true,
            changeYear: true,
            format: "dd.mm.yyyy",
            language: "tr"
        });
    });
    </script>
like image 41
sangram parmar Avatar answered Apr 06 '23 18:04

sangram parmar