You must Sign In to post a response.
  • Category: ASP.NET

    How call google translate onblur in asp.net

    HI,
    I want call google translate function onblur of textbox change. I am calling this function using javascript.

    <script type="text/javascript">
    function changeEnglishToMarathi() {
    // Load the Google Transliterate API
    google.load("elements", "1", {
    packages: "transliteration"
    });

    function onLoad() {
    var options = {
    sourceLanguage:
    google.elements.transliteration.LanguageCode.ENGLISH,
    destinationLanguage:
    [google.elements.transliteration.LanguageCode.MARATHI],
    shortcutKey: 'ctrl+g',
    transliterationEnabled: true
    };

    // Create an instance on TransliterationControl with the required
    // options.
    var control =
    new google.elements.transliteration.TransliterationControl(options);

    // Enable transliteration in the textbox with id
    // 'transliterateTextarea'.
    control.makeTransliteratable(['<%=tbFarmerName .ClientID%>', '<%=tbSearchSurveyNo .ClientID%>', '<%=tbSearchHissaNo .ClientID%>', '<%=tbSearchGathNo .ClientID%>', '<%=tbNewFarmerName .ClientID%>', '<%=tbAddress .ClientID%>', '<%=tbEditFarmerName .ClientID%>', '<%=tbEditAddress .ClientID%>', '<%=tbAssignTo .ClientID%>', '<%=tbContactNo.ClientID%>']);
    }
    google.setOnLoadCallback(onLoad);
    }
    </script>

    <div class="col-sm-6 form-group">
    <b>????????? ???</b><span style="color: Red; font-weight: bolder; font-size: medium;">*</span>
    <asp:TextBox ID="tbNewFarmerName" runat="server" autocomplete="off" placeholder="Enter Farmer Full Name .." onblur ="changeEnglishToMarathi()"
    class="form-control"></asp:TextBox>
    </div>
  • #768271
    Hi,

    Implementation what you have done was fine. Kindly let us know what is the issue you are getting now while trying to execute the code. As per my understanding code are looks fine. Is that Translation is not happening at the time of load?
    Or unable to convert as you desired language?

    Thanks,
    Mani

  • #768272
    Basically you need to changed TextBox to HtmlEditorExtender's editor div, which is under <%=htmlEditorExtender1.ClientID%>_ExtenderContentEditable. Here is the code snippet for translating English to Hindi using Google translation JavaScript
     function onLoad() {
    document.getElementById('<%=htmlEditorExtender1.ClientID%>_ExtenderContentEditable').setAttribute("contentEditable", "true");
    var options = {
    sourceLanguage:
    google.elements.transliteration.LanguageCode.ENGLISH,
    destinationLanguage:
    google.elements.transliteration.LanguageCode.Hindi,
    shortcutKey: 'ctrl+g',
    transliterationEnabled: true
    };
    var control =
    new google.elements.transliteration.TransliterationControl(options);
    control.makeTransliteratable(['<%=htmlEditorExtender1.ClientID%>_ExtenderContentEditable']); //**** changed this
    }
    google.setOnLoadCallback(onLoad);


  • Sign In to post your comments