我引用了This Link 1:how to use kannada font in asp.net?
但是我无法在页面中使用卡纳达语。我想在文本框中输入卡纳达语。
但这没有发生……任何人都可以告诉我这可能是什么原因吗?
我的源代码在这里:
forKannada.css文件
@font-face {font-family:RaghuKannada;
src: url('http://www.cdacmumbai.in/projects/indix/RaghuFonts/RORaghuKannada.ttf');}
home.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Home.aspx.cs" nherits="Home" Culture="kn-IN" UICulture="kn-IN" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//kn-IN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="kn">
<head runat="server">
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="../CSS/forKannada.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<br />
<br />
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Kannada"Font-Names="Tunga" />
</form>
</body>
</html>
Home.aspx.cs文件
public partial class Home : System.Web.UI.Page
{
ResourceManager rm;
CultureInfo ci;
static bool lkannda = false;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
rm = new ResourceManager("Resources.Strings",System.Reflection.Assembly.Load("App_GlobalResources")) ;
ci = Thread.CurrentThread.CurrentCulture;
LoadString(ci);
}
else
{
rm = new ResourceManager("Resources.Strings",System.Reflection.Assembly.Load("App_GlobalResources"));
ci =Thread.CurrentThread.CurrentCulture;
LoadString(ci);
}
}
private void LoadString(CultureInfo ci)
{
Label1.Text = rm.GetString("Name", ci);
Label2.Text = rm.GetString("Desc", ci);
Button1.Text = rm.GetString("AboutMe", ci);
}
protected void Button1_Click(object sender, EventArgs e)
{
if(lkannda)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
LoadString(Thread.CurrentThread.CurrentCulture);
lkannda = false;
}
else
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("kn-IN");
LoadString(Thread.CurrentThread.CurrentCulture);
lkannda = true;
}
}
}
我创建了2个资源文件,一个用于kannada,另一个用于英语,名称分别为Strings.kn-IN.resx和Strings.resx
谁能告诉我这段代码是什么错误。以及如何在文本框中输入kannada,如图所示?我还需要为此代码添加什么?
最佳答案
要使用卡纳达语输入用户信息,您可以按照here所述创建自定义文本框控件
您也可以使用google website Translator摆脱资源文件,该文件可以即时翻译您的页面。您只需要将默认语言设置为卡纳达语