private void ProcessControl(Control ctl, bool includeChildren) { IEditableTextControl e = ctl as IEditableTextControl; if (e != null) { e.Text = ReplaceTokens(e.Text); } else { ITextControl t = ctl as ITextControl; if (t != null) { t.Text = ReplaceTokens(t.Text); } } IValidator v = ctl as IValidator; if (v != null) { v.ErrorMessage = ReplaceTokens(v.ErrorMessage); } // // TODO: Add other controls which might have replaceable properties here // if (includeChildren && ctl.HasControls()) { IterateControls(ctl.Controls); } }
private void ProcessControl(Control ctl, bool includeChildren) { IEditableTextControl e = ctl as IEditableTextControl; if (e != null) { e.Text = ReplaceTokens(e.Text); } else { ITextControl t = ctl as ITextControl; if (t != null) { t.Text = ReplaceTokens(t.Text); } } IValidator v = ctl as IValidator; if (v != null) { v.ErrorMessage = ReplaceTokens(v.ErrorMessage); } if (includeChildren && ctl.HasControls()) { IterateControls(ctl.Controls); } }
protected virtual void FindLocaleStrings(Control c) { try { System.Web.UI.WebControls.Image i = c as System.Web.UI.WebControls.Image; if (i != null) { if (i.ImageUrl.IndexOf("(!") >= 0) { i.ImageUrl = AppLogic.LocateImageURL(i.ImageUrl.Replace("(!SKINID!)", SkinID.ToString()).Replace("(!", string.Empty).Replace("!)", string.Empty), ThisCustomer.LocaleSetting); } if (i.AlternateText.IndexOf("(!") >= 0) { i.AlternateText = AppLogic.GetString(i.AlternateText, SkinID, ThisCustomer.LocaleSetting); } } else { System.Web.UI.WebControls.ImageButton b = c as System.Web.UI.WebControls.ImageButton; if (b != null) { if (b.ImageUrl.IndexOf("(!") >= 0) { b.ImageUrl = AppLogic.LocateImageURL(b.ImageUrl.Replace("(!SKINID!)", SkinID.ToString()).Replace("(!", string.Empty).Replace("!)", string.Empty), ThisCustomer.LocaleSetting); } } else { IEditableTextControl e = c as IEditableTextControl; if (e != null) { if (!(e is ListControl)) { e.Text = AppLogic.GetString(e.Text.Replace("(!SKINID!)", SkinID.ToString()).Replace("(!", "").Replace("!)", ""), SkinID, ThisCustomer.LocaleSetting); } } else { IValidator v = c as IValidator; if (v != null) { v.ErrorMessage = AppLogic.GetString(v.ErrorMessage.Replace("(!SKINID!)", SkinID.ToString()).Replace("(!", "").Replace("!)", ""), SkinID, ThisCustomer.LocaleSetting); } ITextControl t = c as ITextControl; if (t != null) { t.Text = AppLogic.GetString(t.Text.Replace("(!SKINID!)", SkinID.ToString()).Replace("(!", "").Replace("!)", ""), SkinID, ThisCustomer.LocaleSetting); } Button b2 = c as Button; if (b2 != null) { b2.Text = AppLogic.GetString(b2.Text.Replace("(!SKINID!)", SkinID.ToString()).Replace("(!", "").Replace("!)", ""), SkinID, ThisCustomer.LocaleSetting); } LinkButton l = c as LinkButton; if (l != null) { l.Text = AppLogic.GetString(l.Text.Replace("(!SKINID!)", SkinID.ToString()).Replace("(!", "").Replace("!)", ""), SkinID, ThisCustomer.LocaleSetting); } HyperLink h = c as HyperLink; if (h != null) { h.Text = AppLogic.GetString(h.Text.Replace("(!SKINID!)", SkinID.ToString()).Replace("(!", "").Replace("!)", ""), SkinID, ThisCustomer.LocaleSetting); } RadioButton r = c as RadioButton; if (r != null) { r.Text = AppLogic.GetString(r.Text.Replace("(!SKINID!)", SkinID.ToString()).Replace("(!", "").Replace("!)", ""), SkinID, ThisCustomer.LocaleSetting); } } } } if (c.HasControls()) { foreach (Control cx in c.Controls) { FindLocaleStrings(cx); } } } catch { } // for admin site, a hack really, will fix with master pages }
public void SetTextToControl(IEditableTextControl control, string text) { control.Text = text; }