locked
Display day name when date is selected RRS feed

  • Question

  • User-807418713 posted

    Hello

    I use this in my page

    when i select any date without postback i want to show day name 

    for example i select 13 it has to show in Label1 as : TUE

    For example i select 18 it has to show in Label1 as : SUN

    The Day name should be like this SUN,MON,TUE,WED,THU,FRI,SAT...

    How to do without postabck.. thanking you

    Saturday, April 24, 2021 8:24 AM

All replies

  • User-1716253493 posted

    Place label1 in update panel, set fromdate as the update panel trigger.

    In fromdate changed event set label1.text = dtfrom.ToString("ddd")

    dtfrom is datetime type

    Saturday, April 24, 2021 2:28 PM
  • User1535942433 posted

    Hi Gopi.MCA,

    What's your calender? I have created a test with datepicker. And you could set the dateformat. And what's your label?

    Just like this:

    <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
        <link rel="stylesheet" href="/resources/demos/style.css">
        <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
        <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
        <script>
            $(function () {
                $("#datepicker").datepicker({
                    dateFormat: 'DD',
                    changeYear: true,
                    changeMonth: true,
                    onSelect: function (dateText, inst) {
                        $("#Label1").text(dateText);
                    }
                });
            });
        </script>
      <div>
                <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
                Date:
                <div id="datepicker"></div>
            </div>

    Result:

    Best regards,

    Yijing Sun

    Monday, April 26, 2021 5:28 AM
  • User-807418713 posted

    Hello

    Im using asp.net ajax calendar extender in my aspx page

    Thanking You

    Monday, April 26, 2021 7:57 AM
  • User1535942433 posted

    Hi Gopi.MCA,

    I suggest you could change your calendar to date picker. Otherwise,you only use update panel and change the dateformat.

    More details,you could refer to below article:

    https://docs.microsoft.com/en-us/dotnet/api/system.datetime.dayofweek?redirectedfrom=MSDN&view=net-5.0#System_DateTime_DayOfWeek

    Best regards,

    Yijing Sun

    Monday, April 26, 2021 9:46 AM