【问题标题】:Google transliteration not working in update panel谷歌音译在更新面板中不起作用
【发布时间】:2013-12-14 07:31:29
【问题描述】:
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">


    $(document).ready(function () {
        google.load("elements", "1", {
            packages: "transliteration"
        });

        function onLoad() {
            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(['<%=TextBox1.ClientID%>']);
        }

        // here you make the first init when page load
        google.setOnLoadCallback(onLoad);

        // here we make the handlers for after the UpdatePanel update
        var prm = Sys.WebForms.PageRequestManager.getInstance();
        prm.add_initializeRequest(InitializeRequest);
        prm.add_endRequest(EndRequest);

        function InitializeRequest(sender, args) {
        }

        // this is called to re-init the google after update panel updates.
        function EndRequest(sender, args) {
            onLoad();
        }
    });

</script>

    // update panel with button to make post back
                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" />
                    <asp:Label ID="Label1" Text="text" runat="server" />
                    <asp:Button ID="Button1" Text="Postback" runat="server" OnClick="Button1_Click" />
                </ContentTemplate>
            </asp:UpdatePanel>

我已经尝试过这个解决方案Does not work Google translator java Script used to text box in ajax update panel .如果我从页面外部准备好谷歌音译代码,那么它工作正常,但回发后它不起作用。 如果我将代码放在页面就绪事件中,则页面不会加载。请帮我。

【问题讨论】:

  • 请帮助我。它的紧急

标签: javascript asp.net updatepanel google-translator-toolkit


【解决方案1】:

你使用:添加

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:TextBox ID="TextBox1" runat="server" />
                <asp:Label ID="Label1" Text="text" runat="server" />
                <asp:Button ID="Button1" Text="Postback" runat="server" OnClick="Button1_Click" />
            </ContentTemplate>
<Triggers>
        <asp:PostBackTrigger ControlID="Button1" />
</Triggers>
        </asp:UpdatePanel>

【讨论】:

    猜你喜欢
    • 2015-11-29
    • 2014-07-30
    • 2017-01-31
    • 2010-10-13
    • 2011-11-07
    • 2010-10-17
    • 1970-01-01
    相关资源
    最近更新 更多