Get Label Text From Resource File In Asp.net

Get Label Text From Resource File In Asp.net

I have an asp.net webpage, which contains a label, now i want to get the text property of the label from the localresource file, i have a.resx file under App_LocalResources folder, which contains Name as UserNameLabel. Top 2014 Gear. Text and Value as User Name now in my aspx file i am using Label control like this. Aug 30, 2006 I am trying to assign the TEXT property to a internation text translation. My code: Label ID. How to reference Resource files.

Cda Resource File

In a VB.Net Project in VS 2005 I have a form with several labels. I found out that, depending on the amount of the text I enter in the text property via designer the behaviour assigning this text is different. When I enter just a small text, the text is assigned directly to the text property in the Form.Designer.vb file like Me.label1.text = 'Test' If I enter more text, the text is stored in the form resource file and is assigned in the form.Designer.vb file with Me.Label23.Text = resources.GetString( 'Label23.Text' ) I now want to be able to store also smaller texts of my labels in the resource file. Does anybody know how to change this? If I temporarly change the labels text property to a long text ist is stored in the resource, but when I change it back, it is assigned directly. Therefore I prosume, it will not work to manually create the resource and assign it.

If I change the text it will change back. Thanks for all help. Hi, You may try to change the Form1.resx file in the IDE. Add a new string resource, and change the code in the Form1.Designer.vb as below. Me.Label1.Text = resources.GetString('String1') But that is not recommended. If you do not want to store the Text in the Source code, I think you may try to use the AppSetting feature from VS.NET 2005.

You may follow the steps below. Select the Label control on the Form 2. Open its property window 3. Click AppSetttings properties 4. Click the DropDown button by Text 5. Click New and Add a new setting to store the Text property(e.g.MyLabelText) 6. Open the Project Properties page 7.

Click Settings, you will find the setting we created just now. If you still have any concern, please feel free to post here. Best regards, Peter Huang. I mentioned, I prosume that your first solution won't work. Now I tested it and I found out I was right. I can add the ressource and assign it to the Labels text-Property. But if I change it in the designer, VS automatically switch back to assign the text directly in the designer file.

This is no solution for me and also your second suggestion won't work for me in this particular case. I'll explain more detailed what I want to do: I created a wizard with a tab-control to import files.

On one page of the wizard I have a label which say's for example 'Import was successful'. In several cases, when a error occurs, the label should show an error-message. Up to this point it's no problem. But the user then can go back in the wizard and change some settings and try once again. Now the import is successful. So I have to change back the labels text to 'Import was successful'.

My first approach was to set the labels text-property directly in my code, but then I thought what happens if I want to change the text later? I'm sure I'll change the text in the designer for the initial settings of my label, but will I remember that I also have to change my code for resetting the label?

I'm sure I will not. So I thought it would be great to assign the text property via a resource. I can use and change this with the designer and when I reset the text-property in my code I can also use the resource. If I change the text in the designer, the code will use the same new text. But then I run into these problem.

Sure I can use a const to set the text property, but this cannot be changed with the designer. At the moment I have a solution that I store the labels text in a local variable on FormLoad and the use this to reset it. But I'm always looking for straight forward and elegant solutions and if this with the resource would work, it would be the best in my opinion.