Search code examples
asp.netc#-4.0globalizationtabpaneltabcontainer

Auto Post back property not working with tab container


I am applying globalization on my hotel management system web portal and I am stuck with an issue.My issue is that I have a drop down list of two languages English and Spanish and I set autopostback="true" so from drop down I select spanish and my web page successfully convert english language to spanish by calling the method below

 protected override void InitializeCulture()
        {

            if (Request.Form["ctl00$contentplaceholder1$language_drp"] != null)
            {

                UICulture = Request.Form["ctl00$contentplaceholder1$language_drp"];
            }

            base.InitializeCulture();
        }

As I have set autopostback property true so this function get called successfull. and I have also edit control from which I can edit my hotel details in spanish or in english and I have used tab container for all information's of hotels. but when I click on edit my page doesnot post back to true that is why I am unable to call iniliaze culture method and that is why I my page language is not convertable. I applied autopostback property true in tabcontainer but failed. in tab container I have tab panels. here is my code

<asp:TabContainer ID="TabContainerHotelDetails" runat="server" AutoPostBack="true"  
            Width="100%" OnLoad="TabContainerHotelDetails_Load">
            <asp:TabPanel runat="server"  HeaderText="General" ID="TabGeneral" >
                <ContentTemplate>
                    <asp:Panel ID="PanelInfo" runat="server"  Width="100%" GroupingText="<%$ Resources:Resource, LocalizedInformation %>">
                        <table width="100%" border="0" cellpadding="0" cellspacing="0">
                            <tr>
                                <td width="20%">
                                    <table width="100%" border="0" cellpadding="0" cellspacing="0">
                                        <tr>
                                            <td style="padding-top: 10px; height: 30px;">
                                                <asp:Label ID="metaHotelName" runat="server" Text="<%$ Resources:Resource, LocalizedHotelName %>"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding-top: 10px; height: 30px;">
                                                <asp:Label ID="metaHotelStatus" runat="server" Text="<%$ Resources:Resource, LocalizedStatus %>"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding-top: 10px; height: 30px;">
                                                <asp:Label ID="metaMemberShip" runat="server" Text="<%$ Resources:Resource, LocalizedMemberShipType %>"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding-top: 10px; height: 30px;">
                                                <asp:Label ID="metaUserName" runat="server" Text="<%$ Resources:Resource, LocalizedUserName %>"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding-top: 10px; height: 30px;">
                                                <asp:Label ID="metaEmail" runat="server" Text="<%$ Resources:Resource, LocalizedEmail %>"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding-top: 10px; height: 30px;">
                                                <asp:Label ID="metaTotalPoint" runat="server" Text="<%$ Resources:Resource, LocalizedTotalPoint %>"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding-top: 10px; height: 30px;">
                                                <asp:Label ID="metaRegistrationDate" runat="server" Text="<%$ Resources:Resource, LocalizedRegisteredDate %>"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding-top: 10px; height: 30px;">
                                                <asp:Label ID="metaLastLogin" runat="server" Text="<%$ Resources:Resource, LocalizedLastLogin %>"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding-top: 10px; height: 30px;">
                                                <asp:Label ID="metaEmailActivated" runat="server" Text="<%$ Resources:Resource, LocalizedEmailActivated %>"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding-top: 10px; height: 30px;">
                                                <asp:Label ID="metaLockedOut" runat="server" Text="<%$ Resources:Resource, LocalizedLockedOut %>"></asp:Label>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                                <td width="5%" style="border-right: 1px dotted black;">
                                </td>
                                <td>
                                    <table border="0" cellpadding="0" cellspacing="0" style="padding-left: 10px;">
                                        <tr>
                                            <td style="padding-top: 10px; height: 30px;">
                                                <asp:Label ID="lblHotelName" runat="server"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding-top: 10px; height: 30px;">
                                                <asp:Label ID="lblStatus" runat="server"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding-top: 10px; height: 30px;">
                                                <asp:Label ID="lblMembershipType" runat="server"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding-top: 10px; height: 30px;">
                                                <asp:Label ID="lblUserName" runat="server"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding-top: 10px; height: 30px;">
                                                <asp:Label ID="lblEmail" runat="server"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding-top: 10px; height: 30px;">
                                                <asp:Label ID="lblTotalPoints" runat="server"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding-top: 10px; height: 30px;">
                                                <asp:Label ID="lblRegisteredDate" runat="server"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding-top: 10px; height: 30px;">
                                                <asp:Label ID="lblLastLogin" runat="server"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding-top: 10px; height: 30px;">
                                                <asp:CheckBox ID="chkEmailActivated" runat="server" OnCheckedChanged="chkEmailActivated_CheckedChanged"
                                                    AutoPostBack="True" />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding-top: 10px; height: 30px;">
                                                <asp:CheckBox ID="chkLockedOut" runat="server" OnCheckedChanged="chkLockedOut_CheckedChanged"
                                                    AutoPostBack="True" />
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>

Is there any way I can easily do this or alternatives for this so my iniliazeculture method get called after I click on edit. Please help as I am very new to stack overflow. I don't actually know good way to post questions.


Solution

  • here i found answer after two days of my searching. the answer is very simple :)

    i set the value of my language to UICulture

    protected override void InitializeCulture()
            {
                if (Request.Form["ctl00$contentplaceholder1$language_drp"] != null)
                {
    
                    UICulture = Request.Form["ctl00$contentplaceholder1$language_drp"];
                }
                if (Request.QueryString["HotelID"] != null)
                {
    
                    this.UICulture = "es";
                }
                base.InitializeCulture();
            }
    

    and its working fine :)