c# - Different results in same elements that get text value from classes -
in site defined dictionary
returns persian
or english
strings depending on session. here code dictionary:
public static string find_term(string term) { var dictionary = new dictionary<string, string>(); dictionary.add("accommodation barges", "بارج اقامتی"); dictionary.add("bulk carriers", "فله بر"); dictionary.add("barge", "بارج"); dictionary.add("cable layers", "کابل گذار"); dictionary.add("cargo ships", "باربری"); dictionary.add("container ships", "کانتینر بر"); dictionary.add("crew boats", "پرسنل بر"); dictionary.add("cruise ships", "کروز"); dictionary.add("dive boats", "قایق قواصی"); dictionary.add("drilling rigs", "سکوی حفاری"); dictionary.add("fishing boat", "ماهیگیری"); dictionary.add("ferries", "فری"); dictionary.add("floating cranes", "کرن شناور"); dictionary.add("floating hotels", "هتل شناور"); dictionary.add("glass bottom boats", "کف شیشه ای"); dictionary.add("hovercraft", "هاورکرافت"); dictionary.add("hydrofoils", "hydrofoils"); dictionary.add("ice breakers", "یخ شکن"); dictionary.add("life boats", "لایف بوت"); dictionary.add("landing craft", "لندینگ کرافت"); dictionary.add("life rafts", "لایف رافت"); dictionary.add("passenger boats", "مسافر بر"); dictionary.add("patrol boats", "گشت"); dictionary.add("pilot boats", "پایلوت بوت"); dictionary.add("platforms", "پلتفرم"); dictionary.add("research vessels", "تحقیقاتی"); dictionary.add("salvage ships", "از رده خارج"); dictionary.add("supply boats", "ساپلای بوت"); dictionary.add("support vessels", "ساپورت بوت"); dictionary.add("tankers", "تانکر"); dictionary.add("tour boats", "تور"); dictionary.add("towboats", "هدایت کننده"); dictionary.add("tugs", "یدک کش"); dictionary.add("utility boats", "یوتیلیتی بوت"); dictionary.add("all types", "همه نوع"); dictionary.add("login", "ورود"); dictionary.add("register", "ثبت نام"); dictionary.add("logout", "خروج"); dictionary.add("home", "صفحه اصلی"); dictionary.add("news", "تازه ها"); //dictionary.add("builder", "سازنده"); dictionary.add("builder", "سازنده"); dictionary.add("request vessel", "درخواست این شناور"); dictionary.add("ship particular", "مشخصات شناور"); dictionary.add("build year", "سال ساخت"); if (httpcontext.current.session["lang"].tostring() == "fa") { return dictionary[term]; } else { return term; } // // todo: add constructor logic here // }
the returned string being used text attribute of key elements in web site. example below works fine on button located in repeater:
<asp:repeater runat="server" id="vslcat" datasourceid="sqldatasource2"> <itemtemplate> <asp:linkbutton runat="server" text='<%# dict.find_term(eval("vcat").tostring()) %>' postbackurl='<%# request.rawurl + "?vslcat=" + eval("vcat") %>' cssclass="ui-btn ui-mini ui-shadow ui-btn-icon-right ui-icon-carat-r"></asp:linkbutton> </itemtemplate> </asp:repeater>
but in same element out side of repeater returns nothing without error!!!
<asp:linkbutton runat="server" text='<%# dict.find_term("all types")%>' cssclass="ui-btn ui-mini ui-shadow ui-btn-icon-right ui-icon-carat-r" postbackurl="~/default2.aspx" id="btncatallen"></asp:linkbutton> <asp:repeater runat="server" id="vslcat" datasourceid="sqldatasource2"> <itemtemplate> <asp:linkbutton runat="server" text='<%# dict.find_term(eval("vcat").tostring()) %>' postbackurl='<%# request.rawurl + "?vslcat=" + eval("vcat") %>' cssclass="ui-btn ui-mini ui-shadow ui-btn-icon-right ui-icon-carat-r"></asp:linkbutton> </itemtemplate> </asp:repeater>
i don't know problem!!! please let me know if find clues.
when using code block <% %>
in elements attributes <asp:button runat="server" text='<%# ...codes... %>'></asp:button>
outside of element uses data sources, list view or repeater, should use elements id , give go in code behind orrrrr should like:
<asp:hyperlink runat="server" navigationurl="#"><%= ...codes... %></asp:hyperlink>
please note beginning of code block has changed #
=
!!!