c# - Loop through all buttons on a page and assign a new text value -


i've got page has several buttons on page have same text assigned them, , i'm working on localizing page different language based on user's browser culture. hoping programmatically cycle through them , relabel them on fly. i've tried, , causes asp page error:

foreach (button s in page.controls) {     if (s.text =="search")     {        s.text = "buscar";     } } 

you might want consider using resource files, rather looping through controls. example, resource files in place, can define button so:

<asp:button id="btnsave" runat="server" meta:resourcekey="btnsave" text="english button" />

the idea have resx file each language , culture wish support, , each file contain same labels e.g. "btnsave" differing text values.

i suggest resource files as, in long term, prove lot more flexible you.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -