0

I have a partial view page, I want to load JavaScript And CSS files in this partial view.

Please help me how do I do this?

I want to load these three files in Partial View

<link href="~/AdminTheme/BootstrapJalaliDatePicker/css/bootstrap- 
    datepicker.min.css" rel="stylesheet" />
<script src="~/AdminTheme/BootstrapJalaliDatePicker/js/bootstrap- 
    datepicker.min.js"></script>
<script src="~/AdminTheme/BootstrapJalaliDatePicker/js/bootstrap- 
    datepicker.fa.min.js"></script>

Partial View:

<div class="col-md-12">               
    <div class="col-md-6">
        <div class="form-group">
            <label asp-for="StartDate" class="control-label">
                StartDate
            </label>
            <input id="sdDate" class="Date form-control" name="stDate"/>    
            <span asp-validation-for="StartDate" class="error"></span>
        </div>
    </div>
             
    <div class="col-md-6">
        <div class="form-group">
            <label asp-for="EndDate" class="control-label"> 
                EndDate
            </label>
            <input id="edDate" class="Date form-control" name="edDate"/>
            <span asp-validation-for="EndDate" class="error"></span>
        </div>
    </div>
</div>

<script type="text/javascript" language=javascript>                  
    $(document).ready(function() {       
        $('.Date').datepicker({ dateFormat: "yy/mm/dd", isRTL: true, 
            showButtonPanel: true });
    });
 </script>
Guerric P
  • 30,447
  • 6
  • 48
  • 86
zari
  • 29
  • 1
  • 5
  • 1
    Just add it to the partial view. You can add JS and CSS blocks everywhere throughout the HTML, not just in the header. – Thomas Nov 24 '21 at 11:54
  • And what happens when you add them to your partial view? What's not working that made you ask this question? – freedomn-m Nov 24 '21 at 11:57
  • I want the date plugin to be displayed, – zari Nov 24 '21 at 12:02
  • This partial view performs operations in Ajax. After refreshing the page, the date plugin is displayed, but after a record insertion operation, the date plugin is no longer displayed to insert a new record. – zari Nov 24 '21 at 12:15

1 Answers1

0

The solution obtained:

   $(document).on("focusin",".Date", function () {
         $(this).datepicker({
            dateFormat: "yy/mm/dd", 
            isRTL: true, 
            showButtonPanel: true
           });
        });  

add css:

.datepicker{z-index:1151 !important;}
zari
  • 29
  • 1
  • 5