In this article I will explain with an example, how to display Hijri (Islamic) calendar in ASP.Net.
Download Bootstrap Hijri (Islamic) DatePicker Plugin
You will need to download the plugin files from the following location.
The complete documentation can be read on the following page.
HTML Markup
The HTML Markup consists of an ASP.Net TextBox and an ASP.Net Button.
The Button has been assigned an OnClick event handler.
<div class="container">
<div class="row">
<div class="col-md-12">
<asp:TextBox ID="txtHijriDate" type="text" class="form-control" runat="server"></asp:TextBox>
<asp:Button ID="btnHijriDate" Text="HijriDate" runat="server" CssClass="btn btn-primary" OnClick="OnSubmit"/>
</div>
</div>
</div>
Bootstrap Hijri DatePicker Plugin implementation
Inside the HTML Markup, first the following CSS are inherited.
1. bootstrap.min.css
2. bootstrap-datetimepicker.min.css
And then, the following JS scripts are inherited.
1. jquery.min.js
2. moment.min.js
3. moment-hijri.js
4. bootstrap-hijri-datetimepicker.js
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.1/moment.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/moment-hijri@2.1.0/moment-hijri.js"></script>
<script src="assets/js/bootstrap-hijri-datetimepicker.js"></script>
<script type="text/javascript">
$(function () {
$("[id*=txtHijriDate]").hijriDatePicker();
});
</script>
Display MessageBox using ClientScript.RegisterClientScriptBlock
Inside the Button Click event, the value of the selected date is displayed using JavaScript Alert Message Box using the RegisterClientScriptBlock function.
C#
protected void OnSubmit(object sender, EventArgs e)
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('" + txtHijriDate.Text + "')", true);
}
VB.Net
Protected Sub OnSubmit(ByVal sender As Object, ByVal e As EventArgs)
ClientScript.RegisterClientScriptBlock(Me.GetType(), "alert", "alert('" & txtHijriDate.Text & "')", True)
End Sub
Screenshot
Browser Compatibility
The above code has been tested in the following browsers.
* All browser logos displayed above are property of their respective owners.
Demo
Downloads