How to customize CultureInfo's default calendar?

后端 未结 3 1107
后悔当初
后悔当初 2021-02-09 22:53

I want to customize calendar to persian but after setting CultureInfo as this:

CultureInfo fa = new CultureInfo(\"fa-IR\",true);
Thread.CurrentThread.CurrentCult         


        
3条回答
  •  攒了一身酷
    2021-02-09 22:58

    You can set CultureInfo of thread before the control is rendered and restore once the control is rendered.

    Output :

    enter image description here

    Below example show's how you can render two different calendar with different CultureInfo.

    Default.aspx

    <%@Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
    <%@ Import Namespace="System.Globalization" %>
    <%@ Import Namespace="System.Threading" %>
    
    
    
    
    
        
    
    
        
    <% Thread.CurrentThread.CurrentCulture = new CultureInfo("fa-IR");%> <% Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); %>

    Default.aspx.cs

    using System;
    using System.Threading;
    using System.Globalization;
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
    }
    

提交回复
热议问题