Click here to Skip to main content
14,546,974 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have a user control which comprise of a button. Of these button, I want to change the text in different language by different langugageID. Codes as follow:
public class MLButton : Button
   {

       public new string Text
       {
           get
           {
               if (this.DesignMode)
               {
                   return base.Text;
               }
               //To get different language  Text by LanguageID
               return LanguageManager.GetText(LanguageID);
           }
           set
           {
               base.Text = value;
           }
       }


       public AdminStrings LanguageID
       {
           get
           {
               return this.ViewState["LanguageID"];
           }

           set
           {
               this.ViewState["LanguageID"] = value;
           }


Is it possible? Please guide me .Thank you.
Posted
Updated 31-Oct-11 19:27pm
v2
Comments
[no name] 1-Nov-11 1:06am
   
I think it's perfectly correct, what's wrong in it?
harry~ 1-Nov-11 1:40am
   
But it doesn't work,button's text remain its default text,the method "LanguageManager.GetText()" is not run,I don't know how it is happened.
Thank you for your answer.
Nandun 1-Nov-11 1:49am
   
This should work perfectly and I assume
LanguageManager.GetText(LanguageID); is working correctly. If you are getting any error please post that error message so that we can have an idea about your problem.
harry~ 2-Nov-11 1:22am
   
There is no error message when the application running,I found that "public new string Text" is not used by "button" class.According to the definition

of c#'s class,it is hard to understand.

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 2

I changed the codes like that:
public class MLButton : Button
   {


       public AdminStrings LanguageID
       {
           get
           {
               return this.ViewState["LanguageID"];
           }

           set
           {
               this.ViewState["LanguageID"] = value;
              //To get different language  Text by LanguageID
               this.text=return LanguageManager.GetText(LanguageID);

           }

}

and then,buttons can get right language text,but I also don't know how that happened. If you konw,please tell me ,thank you.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100