Friday 21 June 2013

WORKING ASP.Net- Create Hindi TextBox Using Google Transliteration in ASP.Net

WORKING  ASP.Net- Create Hindi TextBox Using Google Transliteration in ASP.Net

http://manish4dotnet.blogspot.in/2013/05/aspnet-create-hindi-textbox-using.html

Here, I am explaining you how to create a hindi textbox in ASP.Net using  Google Transliteration.Here I am mainly targeting english to hindi transliteration. You can use any language which is supported by Google.

To create a Hindi textbox in  ASP.Net using Google Transliteration, you have to add the following script source into your ASPX page.

?
1
2
3
<script src="https://www.google.com/jsapi"
type="text/javascript">
</script>
After adding above script source file, Now write the following java script.
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<script language="javascript" type="text/javascript">
google.load("elements", "1", {packages: "transliteration"});
      
function onLoad() {
 var options = {
    //Source Language
    sourceLanguage: google.elements.transliteration.LanguageCode.ENGLISH,
    // Destination language to Transliterate
    destinationLanguage: [google.elements.transliteration.LanguageCode.HINDI],
    shortcutKey: 'ctrl+g',
    transliterationEnabled: true
 };
      
    var control = new google.elements.transliteration.TransliterationControl(options);
    control.makeTransliteratable(['YourTextBoxClientID']);
     
}
google.setOnLoadCallback(onLoad);
</script>
Here is the full ASPX page code-
Aspx Page

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="MultiPagetoPdf.WebForm1" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Hindi Textbox Demo</title>
   <script src="https://www.google.com/jsapi" type="text/javascript">
    </script>
    <script language="javascript" type="text/javascript">
        google.load("elements", "1", { packages: "transliteration" });
 
        function onLoad() {
            var options = {
                //Source Language
                sourceLanguage: google.elements.transliteration.LanguageCode.ENGLISH,
                // Destination language to Transliterate
                destinationLanguage: [google.elements.transliteration.LanguageCode.HINDI],
                shortcutKey: 'ctrl+g',
                transliterationEnabled: true
            };
 
            var control = new google.elements.transliteration.TransliterationControl(options);
            control.makeTransliteratable(['TextBox1']);
 
        }
        google.setOnLoadCallback(onLoad);
</script>
</head>
<body>
    <form id="form1" runat="server">
   <div>
    <asp:textbox id="TextBox1" runat="server" style="border: 1px solid black; height: 125px; margin-left: auto; width: 550px;" textmode="MultiLine">
</div>
</form>
</body>
</html>


Live Demo



No comments:

Post a Comment