locked
Pass My Label To enable days RRS feed

  • Question

  • User-807418713 posted

    Hello

    This My Script

    <script>  
    
    jQuery(function(){
    
        var enableDays = ["8-7-2018","5-7-2018"];
    
        function enableAllTheseDays(date) {
            var sdate = $.datepicker.formatDate( 'd-m-yy', date)
            if($.inArray(sdate, enableDays) != -1) {
                return [true];
            }
            return [false];
        }
    
        $('#txtCalender').datepicker({dateFormat: 'dd-M-yy', beforeShowDay: enableAllTheseDays});
    })
    </script> 

    I want to pass  var EnableDays = my label1

    My Label1 Look Like This : <asp:Label ID="Label1" runat="server" Text='"8-7-2018","5-7-2018"'></asp:Label>

    Thank You

    Saturday, July 28, 2018 12:03 PM

Answers

  • User-1171043462 posted

    Now 2 is not shown and 29 is shown.

    Quickly check and reply

      <asp:TextBox ID="txtDate" runat="server" ReadOnly="true"></asp:TextBox>
        <%--<asp:Label ID="Label1" runat="server" Text='"06-06-2018" ,"07-06-2018" ,"11-06-2018" ,"20-06-2018" ,"21-06-2018" ,"22-06-2018"'></asp:Label>--%>
        <span id="LD" style="color: blue; font-family: Palatino Linotype; font-size: 12pt;
            font-weight: bold;">"06-06-2018" ,"07-06-2018" ,"11-06-2018" ,"20-06-2018" ,"21-06-2018"
            ,"22-06-2018" ,"23-06-2018" ,"03-07-2018" ,"18-07-2018" ,"20-07-2018" ,"25-07-2018"
            ,"26-07-2018" ,"29-07-2018"</span>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type="text/javascript"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"
            type="text/javascript"></script>
        <link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css"
            rel="Stylesheet" type="text/css" />
        <script type="text/javascript">
            $(function () {
                var enableDays = [];
                //var enableDays = ["8-7-2018", "5-7-2018"];
                $($("#LD").html().split(',')).each(function () {
                    var dt = this.replace(/["]{1}/gi, "");
                    var dt2 = "";
                    $(dt.split('-')).each(function () {
                        dt2 += parseInt(this) + "-";
                    });
                    dt2 = dt2.substring(0, dt2.length - 1);
                    enableDays.push(dt2);
                });
                function enableAllTheseDays(date) {
                    var sdate = $.datepicker.formatDate('d-m-yy', date);
                    if ($.inArray(sdate, enableDays) != -1) {
                        return [true];
                    }
                    return [false];
                }
                $("[id*=txtDate]").datepicker({
                    showOn: 'button',
                    buttonImageOnly: true,
                    buttonImage: 'images/calendar.png',
                    beforeShowDay: enableAllTheseDays
                });
            });
        </script>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 30, 2018 1:45 PM
  • User-369506445 posted

    hi

    I fixed <g class="gr_ gr_33 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace" id="33" data-gr-id="33">it ,</g> please try it

    DEMO

    <title></title>
         <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type="text/javascript"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"
            type="text/javascript"></script>
        <link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css"
            rel="Stylesheet" type="text/css" />
        
    
        <script type="text/javascript">
            $(function () {
                var enableDays = [];
              
                var arr = $("#LD").html().replace(/["']{1}/gi, "").split(",");
                for (var i = 0; i < arr.length; i++) {
                    enableDays.push($.trim(arr[i]));
                }
                
    
                function enableAllTheseDays(date) {
                    var sdate = $.datepicker.formatDate('dd-mm-yy', date);
                    if ($.inArray(sdate, enableDays) != -1) {
                        return [true];
                    }
                    return [false];
    
                }
                $("[id*=txtDate]").datepicker({
                    showOn: 'button',
                    buttonImageOnly: false,             
                    beforeShowDay: enableAllTheseDays
                });
            });
        </script>
    
      <asp:TextBox ID="txtDate" runat="server" ReadOnly="true"></asp:TextBox>
                        <span id="LD" style="color: blue; font-family: Palatino Linotype; font-size: 12pt; font-weight: bold;">"06-06-2018" ,"07-06-2018" ,"11-06-2018" ,"20-06-2018" ,"21-06-2018" ,"22-06-2018" ,"23-06-2018" ,"03-07-2018" ,"18-07-2018" ,"20-07-2018" ,"25-07-2018" ,"26-07-2018" ,"29-07-2018"</span>

    result

    I hope it can be helpful

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 30, 2018 2:40 PM

All replies

  • User-1171043462 posted

    Gopi.MCA

    var enableDays = ["8-7-2018","5-7-2018"];

    Change to

    var enableDays = $("[id*=Label1]").html().split(',');

    Saturday, July 28, 2018 2:35 PM
  • User-807418713 posted

    Hello Sir

    Here Is My Complete ASpx Code

    But Date not working which is in label why?

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="TT.aspx.cs" Inherits="TT" %>
    
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title></title>
    <link href="jquery-ui.css" rel="stylesheet" />  
    <script src="jquery-3.2.1.min.js"></script>  
    <script src="jquery-ui.js"></script>  
    
    
    <script>  
    
    jQuery(function(){
    
      // var enableDays = ["8-7-2018","5-7-2018"];
        var enableDays =  $("[id*=Label1]").html().split(',');
    
        function enableAllTheseDays(date) {
            var sdate = $.datepicker.formatDate( 'd-m-yy', date)
            if($.inArray(sdate, enableDays) != -1) {
                return [true];
            }
            return [false];
        }
    
        $('#txtCalender').datepicker({dateFormat: 'dd-M-yy', changeMonth: true, changeYear: true, yearRange: '2018:2200',beforeShowDay: enableAllTheseDays});
    })
    </script>  
    </head>
    <body>
        <form id="form1" runat="server">
      
       <asp:HiddenField ID="hidden" runat="server" />
        
            <asp:TextBox ID="txtCalender" runat="server" />
            <asp:Label ID="Label1" runat="server" Text='"8-7-2018","5-7-2018"'></asp:Label>
            
        </form>
    </body>
    </html>
    

    Sunday, July 29, 2018 6:15 AM
  • User-369506445 posted

    hi

    your problem is here

    Text='"8-7-2018","5-7-2018"'

    when you split it, the result be "8-7-2018" and "5-7-2018"

    but your

     var sdate = $.datepicker.formatDate( 'd-m-yy', date)

    result be 8-7-2018

    namely

    if (8-7-2018=="8-7-2018")  it is not eqaul

    you have to remove <g class="gr_ gr_9 gr-alert gr_gramm gr_inline_cards gr_run_anim Punctuation only-del replaceWithoutSep" id="9" data-gr-id="9">""</g> in your label

    <asp:Label ID="Label1" runat="server" Text='8-7-2018,5-7-2018'></asp:Label>

    Sunday, July 29, 2018 7:16 AM
  • User-1171043462 posted

    Here;s complete example

     <asp:TextBox ID="txtDate" runat="server" ReadOnly="true"></asp:TextBox>
        <asp:Label ID="Label1" runat="server" Text='"8-7-2018","5-7-2018"'></asp:Label>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type="text/javascript"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"
            type="text/javascript"></script>
        <link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css"
            rel="Stylesheet" type="text/css" />
        <script type="text/javascript">
            $(function () {
                var enableDays = [];
                //var enableDays = ["8-7-2018", "5-7-2018"];
                $($("[id*=Label1]").html().split(',')).each(function () {
                    var dt = this.substring(1, this.length - 1);
                    enableDays.push(dt);
                });
                function enableAllTheseDays(date) {
                    var sdate = $.datepicker.formatDate('d-m-yy', date);
                    if ($.inArray(sdate, enableDays) != -1) {
                        return [true];
                    }
                    return [false];
                }
                $("[id*=txtDate]").datepicker({
                    showOn: 'button',
                    buttonImageOnly: true,
                    buttonImage: 'images/calendar.png',
                    beforeShowDay: enableAllTheseDays
                });
            });
        </script>

    Sunday, July 29, 2018 7:40 AM
  • User-807418713 posted

    Hello

    My Date Is Like This Format In Label

    "06-06-2018" ,"07-06-2018" ,"11-06-2018" ,"20-06-2018" ,"21-06-2018" ,"22-06-2018"

    What To Change..

    </form>

    Monday, July 30, 2018 8:18 AM
  • User-369506445 posted

    please try below

            <asp:TextBox ID="txtDate" runat="server" ReadOnly="true"></asp:TextBox>
            <asp:Label ID="Label1" runat="server" Text='"06-06-2018" ,"07-06-2018" ,"11-06-2018" ,"20-06-2018" ,"21-06-2018" ,"22-06-2018"'></asp:Label>
            <asp:Label ID="Label2" runat="server" Text='"8-7-2018","5-7-2018"'></asp:Label>
    
            <script type="text/javascript">
                $(function () {
                    var enableDays = [];
                    //var enableDays = ["8-7-2018", "5-7-2018"];
                    $($("[id*=Label1]").html().split(',')).each(function () {
                        var dt = this.replace(/["']{1}/gi, "");
                        enableDays.push(dt);
                    });
                    function enableAllTheseDays(date) {
                        var sdate = $.datepicker.formatDate('dd-mm-yyyy', date);
                        if ($.inArray(sdate, enableDays) != -1) {
                            return [true];
                        }
                        return [false];
                    }
                    $("[id*=txtDate]").datepicker({
                        showOn: 'button',
                        buttonImageOnly: true,
                        buttonImage: 'images/calendar.png',
                        beforeShowDay: enableAllTheseDays
                    });
                });
            </script>

    Monday, July 30, 2018 9:23 AM
  • User-807418713 posted

    Hello Vahid

    Your Label 1 Is showing like this

     <asp:Label ID="Label1" runat="server" Text='"06-06-2018" ,"07-06-2018" ,"11-06-2018" ,"20-06-2018" ,"21-06-2018" ,"22-06-2018"'></asp:Label>

    my label1 is like this data

    "06-06-2018" ,"07-06-2018" ,"11-06-2018" ,"20-06-2018" ,"21-06-2018" ,"22-06-2018"

    Code not working

    Monday, July 30, 2018 10:55 AM
  • User-369506445 posted

    I did n't get different between them, please put a complete tag of your Label like me

    Monday, July 30, 2018 11:03 AM
  • User-807418713 posted

    Hello

    This is my sql query im bind this to my label

    CREATE TABLE TAB (ProcessDate DATETIME)
    DECLARE   @sPeriodList VARCHAR(MAX)
    
    INSERT INTO TAB
    SELECT '2018-06-21 00:00:00.000' UNION ALL
    SELECT '2018-06-21 00:00:00.000' UNION ALL
    SELECT '2018-06-03 00:00:00.000' UNION ALL
    SELECT '2018-06-28 00:00:00.000' UNION ALL
    SELECT '2018-06-28 00:00:00.000' UNION ALL
    SELECT '2018-07-01 00:00:00.000' UNION ALL
    SELECT '2018-07-05 00:00:00.000'
    
    SELECT @sPeriodList = STUFF((
        SELECT DISTINCT ',"' + CONVERT(VARCHAR(20), ProcessDate, 105) + '"' AS [data()]
        FROM    TAB
        FOR XML PATH('')
    ),1,1,'')
    
    SELECT @sPeriodList AS ProcessDates
    
    DROP TABLE TAB

    Hope this clear

    Monday, July 30, 2018 11:06 AM
  • User-369506445 posted

    <g class="gr_ gr_24 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace" id="24" data-gr-id="24">no ,</g> my mean was where did you hold your database result for example in <g class="gr_ gr_90 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins doubleReplace replaceWithoutSep" id="90" data-gr-id="90">variable</g> or <g class="gr_ gr_94 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar multiReplace" id="94" data-gr-id="94">a input</g> <g class="gr_ gr_109 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="109" data-gr-id="109">lable</g> or ...

    please put it for me

    Monday, July 30, 2018 11:09 AM
  • User-807418713 posted

    Hello

    That Sql resultset will bind in this format

    if (dt.Rows.Count > 0)
    {
    for (int i = 0; i < dt.Rows.Count; i++)
    {
    LD.Text = dt.Rows[i]["PlanDates"].ToString();
    }

    }

    aspx code

    <asp:Label ID="LD" runat="server" Font-Bold="True" Font-Names="Palatino Linotype"
    Font-Size="12pt" ForeColor="Blue" ></asp:Label>

    Monday, July 30, 2018 11:22 AM
  • User-369506445 posted

    Did you mean this?

    <link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.css" rel="stylesheet" />
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type="text/javascript"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"
            type="text/javascript"></script>
    
     
            <asp:TextBox ID="txtDate" runat="server" ReadOnly="true"></asp:TextBox>
            <asp:Label ID="Label1" runat="server" Text='"06-06-2018" ,"07-06-2018" ,"11-06-2018" ,"20-06-2018" ,"21-06-2018" ,"22-06-2018"'></asp:Label>
     
            <script type="text/javascript">
                $(function () {
                    
                    var enableDays = [];
                    var str = '"01-07-2018" ,"03-06-2018" ,"05-07-2018" ,"21-06-2018" ,"28-06-2018"';
                    var arr = str.split(',');
                    for (var i = 0; i < arr.length; i++)
                    {
                        var dt = arr[i].replace(/["']{1}/gi, ""); // remove "" from the string
                        enableDays.push(dt);
                    }
                    
                    function enableAllTheseDays(date) {
                        var sdate = $.datepicker.formatDate('dd-mm-yyyy', date);
                        if ($.inArray(sdate, enableDays) != -1) {
                            return [true];
                        }
                        return [false];
                    }
                    $("[id*=txtDate]").datepicker({
                        showOn: 'button',
                        buttonImageOnly: true,
                        buttonImage: 'images/calendar.png',
                        beforeShowDay: enableAllTheseDays
                    });
                });
            </script>

    Monday, July 30, 2018 11:22 AM
  • User-1171043462 posted

    @Gopi

    What's problem with my code?

    Monday, July 30, 2018 11:26 AM
  • User-1171043462 posted

    Here's tested and working code.

    Reason why my previous code stopped working because of prefix 0 in dates.

    jQuery fails if you have dates like 07-06-2018 and hence it has to be changed to 7-6-2018

    <asp:TextBox ID="txtDate" runat="server" ReadOnly="true"></asp:TextBox>
        <asp:Label ID="Label1" runat="server" Text='"06-06-2018" ,"07-06-2018" ,"11-06-2018" ,"20-06-2018" ,"21-06-2018" ,"22-06-2018"'></asp:Label>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type="text/javascript"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"
            type="text/javascript"></script>
        <link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css"
            rel="Stylesheet" type="text/css" />
        <script type="text/javascript">
            $(function () {
                var enableDays = [];
                //var enableDays = ["8-7-2018", "5-7-2018"];
                $($("[id*=Label1]").html().split(',')).each(function () {
                    var dt = this.substring(0, this.length - 6).replace(/["0]{1}/gi, "") + this.substring(this.length - 6, this.length - 2);
                    enableDays.push(dt);
                });
                function enableAllTheseDays(date) {
                    var sdate = $.datepicker.formatDate('d-m-yy', date);
                    if ($.inArray(sdate, enableDays) != -1) {
                        return [true];
                    }
                    return [false];
                }
                $("[id*=txtDate]").datepicker({
                    showOn: 'button',
                    buttonImageOnly: true,
                    buttonImage: 'images/calendar.png',
                    beforeShowDay: enableAllTheseDays
                });
            });
        </script>

    Monday, July 30, 2018 11:43 AM
  • User-807418713 posted

    Hello 

    My Date SQL Query is like this

    CREATE TABLE TAB (ProcessDate DATETIME)
    DECLARE   @sPeriodList VARCHAR(MAX)
    
    INSERT INTO TAB
    SELECT '2018-06-21 00:00:00.000' UNION ALL
    SELECT '2018-06-21 00:00:00.000' UNION ALL
    SELECT '2018-06-03 00:00:00.000' UNION ALL
    SELECT '2018-06-28 00:00:00.000' UNION ALL
    SELECT '2018-06-28 00:00:00.000' UNION ALL
    SELECT '2018-07-01 00:00:00.000' UNION ALL
    SELECT '2018-07-05 00:00:00.000'
    
    SELECT @sPeriodList = STUFF((
        SELECT DISTINCT ',"' + CONVERT(VARCHAR(20), ProcessDate, 105) + '"' AS [data()]
        FROM    TAB
        FOR XML PATH('')
    ),1,1,'')
    
    SELECT @sPeriodList AS ProcessDates
    
    DROP TABLE TAB

    Its bind to label like this method

    if (dt.Rows.Count > 0)
    {
    for (int i = 0; i < dt.Rows.Count; i++)
    {
    LD.Text = dt.Rows[i]["PlanDates"].ToString();
    }

    }

    aspx code

    <asp:Label ID="LD" runat="server" Font-Bold="True" Font-Names="Palatino Linotype"
    Font-Size="12pt" ForeColor="Blue" ></asp:Label>

    some date is shoing some not so i share my sql code.. easy to understand

    Monday, July 30, 2018 12:16 PM
  • User-1171043462 posted

    Hi Gopi,

    Just give me value from database set in Label.

    So that I can put in my Label and check

    Monday, July 30, 2018 12:17 PM
  • User-807418713 posted

    Hello

    Here is my data binding from sql to label

    <span id="LD" style="color: blue; font-family: Palatino Linotype; font-size: 12pt; font-weight: bold;">"06-06-2018" ,"07-06-2018" ,"11-06-2018" ,"20-06-2018" ,"21-06-2018" ,"22-06-2018" ,"23-06-2018" ,"03-07-2018" ,"18-07-2018" ,"20-07-2018" ,"25-07-2018" ,"26-07-2018" ,"29-07-2018"</span>

    Monday, July 30, 2018 1:06 PM
  • User-807418713 posted

    Here Is the screenshot of chrome 

    Monday, July 30, 2018 1:10 PM
  • User-1171043462 posted

    My code works

      <span id="LD" style="color: blue; font-family: Palatino Linotype; font-size: 12pt;
            font-weight: bold;">"06-06-2018" ,"07-06-2018" ,"11-06-2018" ,"20-06-2018" ,"21-06-2018"
            ,"22-06-2018" ,"23-06-2018" ,"03-07-2018" ,"18-07-2018" ,"20-07-2018" ,"25-07-2018"
            ,"26-07-2018" ,"29-07-2018"</span>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type="text/javascript"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"
            type="text/javascript"></script>
        <link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css"
            rel="Stylesheet" type="text/css" />
        <script type="text/javascript">
            $(function () {
                var enableDays = [];
                //var enableDays = ["8-7-2018", "5-7-2018"];
                $($("#LD").html().split(',')).each(function () {
                    var dt = this.substring(0, this.length - 6).replace(/["0]{1}/gi, "") + this.substring(this.length - 6, this.length - 2);
                    enableDays.push(dt);
                });
                function enableAllTheseDays(date) {
                    var sdate = $.datepicker.formatDate('d-m-yy', date);
                    if ($.inArray(sdate, enableDays) != -1) {
                        return [true];
                    }
                    return [false];
                }
                $("[id*=txtDate]").datepicker({
                    showOn: 'button',
                    buttonImageOnly: true,
                    buttonImage: 'images/calendar.png',
                    beforeShowDay: enableAllTheseDays
                });
            });
        </script>

    Just need to change Label ID

    Monday, July 30, 2018 1:11 PM
  • User-369506445 posted

    please try below

    <link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.css" rel="stylesheet" />
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type="text/javascript"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"
            type="text/javascript"></script>
           
             <span id="LD" style="color: blue; font-family: Palatino Linotype; font-size: 12pt; font-weight: bold;">"06-06-2018" ,"07-06-2018" ,"11-06-2018" ,"20-06-2018" ,"21-06-2018" ,"22-06-2018" ,"23-06-2018" ,"03-07-2018" ,"18-07-2018" ,"20-07-2018" ,"25-07-2018" ,"26-07-2018" ,"29-07-2018"</span>
    
            <script type="text/javascript">
                $(function () {
                    
                    var enableDays = [];
                    var str = $("#LD").html();
                    var arr = str.split(',');
                    for (var i = 0; i < arr.length; i++)
                    {
                        var dt = arr[i].replace(/["']{1}/gi, ""); // remove "" from the string
                        alert(dt);
                        enableDays.push(dt);
                    }
                    
                    function enableAllTheseDays(date) {
                        var sdate = $.datepicker.formatDate('dd-mm-yyyy', date);
                        if ($.inArray(sdate, enableDays) != -1) {
                            return [true];
                        }
                        return [false];
                    }
                    $("[id*=txtDate]").datepicker({
                        showOn: 'button',
                        buttonImageOnly: true,
                        buttonImage: 'images/calendar.png',
                        beforeShowDay: enableAllTheseDays
                    });
                });
            </script>

    Monday, July 30, 2018 1:14 PM
  • User-807418713 posted

    Hello Vahid

    First time alert shows blank

    Then after its keep showing perfect date in alert message

    but date is not enabling why..?

    Monday, July 30, 2018 1:27 PM
  • User-1171043462 posted

    @Gopi,

    My code does work, but you still say it does not?

    Monday, July 30, 2018 1:30 PM
  • User-807418713 posted

    If i use your code it showing 

    Date

    3

    18

    25 

    26

    only but 2 is not there in result and 29 not showing which is in label

    Monday, July 30, 2018 1:34 PM
  • User-369506445 posted

    try this

    <link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.css" rel="stylesheet" />
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type="text/javascript"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"
            type="text/javascript"></script>
    
     
            <asp:TextBox ID="txtDate" runat="server" ReadOnly="true"></asp:TextBox>
            <asp:Label ID="Label1" runat="server" Text='"06-06-2018" ,"07-06-2018" ,"11-06-2018" ,"20-06-2018" ,"21-06-2018" ,"22-06-2018"'></asp:Label>
            <span id="LD" style="color: blue; font-family: Palatino Linotype; font-size: 12pt; font-weight: bold;">"06-06-2018" ,"07-06-2018" ,"11-06-2018" ,"20-06-2018" ,"21-06-2018" ,"22-06-2018" ,"23-06-2018" ,"03-07-2018" ,"18-07-2018" ,"20-07-2018" ,"25-07-2018" ,"26-07-2018" ,"29-07-2018"</span>
    
            <script type="text/javascript">
                $(function () {
    
                    
                    var enableDays = [];
                    var str = $("#LD").html();
                    var arr = str.split(',');
                    for (var i = 0; i < arr.length; i++)
                    {
                        var dt = arr[i].replace(/["']{1}/gi, ""); // remove "" from the string
                        
                        enableDays.push(dt);
                    }
                    
                    function enableAllTheseDays(date) {
                         var sdate = $.datepicker.formatDate('d-m-yy', date);
                        if ($.inArray(sdate, enableDays) != -1) {
                            return [true];
                        }
                        return [false];
                    }
                    $("[id*=txtDate]").datepicker({
                        showOn: 'button',
                        buttonImageOnly: true,
                        buttonImage: 'images/calendar.png',
                        beforeShowDay: enableAllTheseDays
                    });
                });
            </script>

    Monday, July 30, 2018 1:37 PM
  • User-1171043462 posted

    Now 2 is not shown and 29 is shown.

    Quickly check and reply

      <asp:TextBox ID="txtDate" runat="server" ReadOnly="true"></asp:TextBox>
        <%--<asp:Label ID="Label1" runat="server" Text='"06-06-2018" ,"07-06-2018" ,"11-06-2018" ,"20-06-2018" ,"21-06-2018" ,"22-06-2018"'></asp:Label>--%>
        <span id="LD" style="color: blue; font-family: Palatino Linotype; font-size: 12pt;
            font-weight: bold;">"06-06-2018" ,"07-06-2018" ,"11-06-2018" ,"20-06-2018" ,"21-06-2018"
            ,"22-06-2018" ,"23-06-2018" ,"03-07-2018" ,"18-07-2018" ,"20-07-2018" ,"25-07-2018"
            ,"26-07-2018" ,"29-07-2018"</span>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type="text/javascript"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"
            type="text/javascript"></script>
        <link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css"
            rel="Stylesheet" type="text/css" />
        <script type="text/javascript">
            $(function () {
                var enableDays = [];
                //var enableDays = ["8-7-2018", "5-7-2018"];
                $($("#LD").html().split(',')).each(function () {
                    var dt = this.replace(/["]{1}/gi, "");
                    var dt2 = "";
                    $(dt.split('-')).each(function () {
                        dt2 += parseInt(this) + "-";
                    });
                    dt2 = dt2.substring(0, dt2.length - 1);
                    enableDays.push(dt2);
                });
                function enableAllTheseDays(date) {
                    var sdate = $.datepicker.formatDate('d-m-yy', date);
                    if ($.inArray(sdate, enableDays) != -1) {
                        return [true];
                    }
                    return [false];
                }
                $("[id*=txtDate]").datepicker({
                    showOn: 'button',
                    buttonImageOnly: true,
                    buttonImage: 'images/calendar.png',
                    beforeShowDay: enableAllTheseDays
                });
            });
        </script>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 30, 2018 1:45 PM
  • User-369506445 posted

    hi

    I fixed <g class="gr_ gr_33 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace" id="33" data-gr-id="33">it ,</g> please try it

    DEMO

    <title></title>
         <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type="text/javascript"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"
            type="text/javascript"></script>
        <link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css"
            rel="Stylesheet" type="text/css" />
        
    
        <script type="text/javascript">
            $(function () {
                var enableDays = [];
              
                var arr = $("#LD").html().replace(/["']{1}/gi, "").split(",");
                for (var i = 0; i < arr.length; i++) {
                    enableDays.push($.trim(arr[i]));
                }
                
    
                function enableAllTheseDays(date) {
                    var sdate = $.datepicker.formatDate('dd-mm-yy', date);
                    if ($.inArray(sdate, enableDays) != -1) {
                        return [true];
                    }
                    return [false];
    
                }
                $("[id*=txtDate]").datepicker({
                    showOn: 'button',
                    buttonImageOnly: false,             
                    beforeShowDay: enableAllTheseDays
                });
            });
        </script>
    
      <asp:TextBox ID="txtDate" runat="server" ReadOnly="true"></asp:TextBox>
                        <span id="LD" style="color: blue; font-family: Palatino Linotype; font-size: 12pt; font-weight: bold;">"06-06-2018" ,"07-06-2018" ,"11-06-2018" ,"20-06-2018" ,"21-06-2018" ,"22-06-2018" ,"23-06-2018" ,"03-07-2018" ,"18-07-2018" ,"20-07-2018" ,"25-07-2018" ,"26-07-2018" ,"29-07-2018"</span>

    result

    I hope it can be helpful

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 30, 2018 2:40 PM