How to add a calendar to the presentation page?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
5 years ago
How to add a calendar to the presentation page?

Thanks
5 years ago
You may use Query Datepicker for this purpose.

https://www.jqueryscript.net/time-clock/Highly-Customizable-jQuery-Datepicker-Plugin-Datepicker.html

Have a look on Demo Page:
https://www.jqueryscript.net/demo/Highly-Customizable-jQuery-Datepicker-Plugin-Datepicker/
5 years ago
rmahbub63 wrote:
You may use Query Datepicker for this purpose.

https://www.jqueryscript.net/time-clock/Highly-Customizable-jQuery-Datepicker-Plugin-Datepicker.html

Have a look on Demo Page:
https://www.jqueryscript.net/demo/Highly-Customizable-jQuery-Datepicker-Plugin-Datepicker/


How to transfer the date to the controller from the calendar.

I have already posted a calendar in the view.


<div data-toggle="datepicker"></div>

<script>
  $('[data-toggle="datepicker"]').datepicker({
  });
</script>


Thanks!
5 years ago
I hope the following example will help you.


Model:

public class MyModel : BaseNopModel
{
   public DateTime DateValue { get; set; }
}

View.cshtml:

@model MyModel
@{
    Layout = "_AdminLayout";
}

<script>
    $(document).ready(function () {
        $("#submitButton").click(function (e) {
            $("#loadingData").css("display", "block");
            var postData = {
                DateValue: $("#DateValue").val()
            };
            addAntiForgeryToken(postData);
            $.ajax({
                url: "/Admin/Controller/Action",
                data: postData,
                type: 'post',
                success: function (response) {
                    alert("Done");
                },
                error: function (response) {
                    alert("Opssss something going wrong");
                }
            });

        });
    });
</script>
<form asp-controller="Controller" asp-action="Action" method="post">
    <div class="content-header clearfix">
        <h1 class="pull-left">
            Your Header
        </h1>
    </div>
    <div class="panel-group">
        <div class="panel panel-default">
            <div class="panel-body">
                <div class="form-group">
                    <div class="col-md-3">
                        <nop-label asp-for="DateValue" />
                    </div>
                    <div class="col-md-9">
                        <nop-editor asp-for="DateValue" />
                        <span asp-validation-for="DateValue"></span>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-9 col-md-offset-3">
                        <input type="button" id="submitButton" name="save" class="btn bg-blue" value="@T("Admin.Common.Save")" />
                    </div>
                </div>
            </div>
        </div>
    </div>
</form>

Controller:

[HttpPost]
public IActionResult Action(MyModel myModel)
{
  string date = myModel.DateValue.ToString("dd-MMM-yyyy");
  return View();
}
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.