Srinivas
Srinivas

Reputation: 11

Google Language Dropdown Widget - On Ajax Page

I have a Google language Drop-down widget on my ASP.NET page. This page contains cascading drop-downs. That is, on selection of value from the first drop-down, will fill the other.

The problem i am facing is, if i select the language first from Google language drop-down and then change the value from first drop-down, the values in the second drop-down are not persisting to the changed language. I am sure that this is happening because of Async Postback. But, If I do this with EnableAjax Property to false, this is working. I am using Telerik RadAjaxManager to implement Ajax. Please find the code attached here

<html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Test Page - ASP.NET</title>
    </head>

    <form id="form1" runat="server">
        <asp:ScriptManager runat="server" ID="scrpt1">
        </asp:ScriptManager>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" EnableAJAX="true">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="ddl">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="DropDownList2" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <div>
            <div id="google_translate_element">
            </div>

            <script type="text/javascript">
                    function googleTranslateElementInit() 
                    {
                        new google.translate.TranslateElement({ pageLanguage: 'en', layout: google.translate.TranslateElement.InlineLayout.SIMPLE}, 'google_translate_element');
                    }
            </script>
            <script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
            <br />
            <br />
            <asp:DropDownList runat="server" ID="ddl" AutoPostBack="true">
                <asp:ListItem Text="A"></asp:ListItem>
                <asp:ListItem Text="B"></asp:ListItem>
                <asp:ListItem Text="C"></asp:ListItem>
                <asp:ListItem Text="D"></asp:ListItem>
            </asp:DropDownList>
            <br />
            <br />
            <asp:DropDownList runat="server" ID="DropDownList2" />
        </div>
        </form>
    </html>

Code Behind

          Private Sub ddl_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddl.SelectedIndexChanged 
            DropDownList2.Items.Add(ddl.SelectedItem.Text)
        End Sub

Please let me know if I can achieve this with Ajax Enabled.

Thanks, Srinivas

Upvotes: 1

Views: 476

Answers (0)

Related Questions