The idea is pretty simple: A web user control for ASP.NET that loads the Avro Phonetic keyboard and binds the text inputs and text areas.
The control can be downloaded from: http://masnun.googlecode.com/files/Avro.zip
How to use it?
1) Extract Avro.zip and you shall get two files in the Avro folder: “Avro.ascx” and “Avro.ascx.cs”. First one is the user control and second one is the codebehind file.
2) Crate a new website project in Visual Studio or open your existing project.
3) Copy the above mentioned two files (NOT the entire directory, just the files) into your project. For better organization you might want to create a “Controls” directory (if you haven’t already). Paste the two files inside your desired directory.
4) Now, we add the controls to a web form. Open a page, say Default.aspx. Just below the Page directives, add the following Register directives to register the control:
1 |
<%@ Register Src="~/Controls/Avro.ascx" TagPrefix="asp" TagName="Avro" %> |
Here, Src is the location to the Avro.ascx file. TagPrefix and TagName makeup the custom tag that loads the control. In this case, you now have a <asp:Avro> tag which you can use to load the control.
5) Let’s add the control:
1 |
<asp:Avro Bangla="true" Callback="avro_callback" runat="server" /> |
The control accepts two attributes – “Bangla” and “Callback”. Setting Bangla to “true” or “false” enables or disables Bangla by default. The Callback attribute accepts the name of a Javascript function which is called when the keyboard state changes.
6) Let’s test the control by adding a text area and the defined callback function:
1 2 3 4 5 6 7 |
<textarea></textarea> <script type="text/javascript"> function avro_callback(isBangla) { console.log(isBangla); } </script> |
Load the web page in your browser. If you have Firebug installed in Firefox, the callback should print out state of the Bangla layout on the console.
For brevity, here is my entire Default.aspx file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <%@ Register Src="~/Controls/Avro.ascx" TagPrefix="asp" TagName="Avro" %> <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> </asp:Content> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <asp:Avro Bangla="true" Callback="avro_callback" runat="server" /> <textarea></textarea> <script type="text/javascript"> function avro_callback(isBangla) { console.log(isBangla); } </script> </asp:Content> |