Getting text from the Resource file in asp.net 4

后端 未结 1 879
余生分开走
余生分开走 2021-01-20 19:19

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

相关标签:
1条回答
  • 2021-01-20 19:54

    First you need to create appropriate structure inside web project. In this case I will be using Default.aspx:

    enter image description here

    Take notice I have placed Default.aspx.resx file inside App_LocalResources.

    Next enter new item inside Default.aspx.resx like this:

    enter image description here

    The important thing is you need to set Text property (UserNameLabel.Text)

    And finally here is aspx code:

    <asp:Label ID="UserNameLabel" runat="server" meta:resourcekey="UserNameLabel"></asp:Label>
    

    I have used meta:resourcekey to link to appropriate resource key.

    0 讨论(0)
提交回复
热议问题