Re: loop througth Literials using foreach!!
From: Scott Allen (scott_at_nospam.odetocode.com)
Date: 02/11/05
- Next message: DalePres: "Re: loop througth Literials using foreach!!"
- Previous message: DalePres: "Re: loop througth Literials using foreach!!"
- In reply to: Islam Elkhayat: "Re: loop througth Literials using foreach!!"
- Next in thread: Patrick Olurotimi Ige: "Re: loop througth Literials using foreach!!"
- Reply: Patrick Olurotimi Ige: "Re: loop througth Literials using foreach!!"
- Reply: Islam Elkhayat: "Re: loop througth Literials using foreach!!"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 10 Feb 2005 20:37:02 -0500
If there is a literal control on the page, the control has to be
instantiated to render. Perhaps you meant you didn't want to declare a
variable for each Literal control?
In any case, I think a cleaner solution would be to create a new
control (pehaps derived from Literal or WebControl) and use the Init
event to get the string from a resource file. You could add Key as a
public property to be able to assign the key from inside the ASPX tag.
The above approach will be a cleaner, more maintainable solution.
You'll be able to use the new control on any page in your application
without cluttering eeach page with the string loading logic.
HTH,
-- Scott http://www.OdeToCode.com/blogs/scott/ On Fri, 11 Feb 2005 03:13:07 +0200, "Islam Elkhayat" <islamegy@yahoo.com> wrote: >I want to loop throught literials so i don't use >Lit_1.Text= resources.GetString(key) >for each literial... if i instantiated every literial in the code behind i >will write the same long code!!! >How can i solve this issue?? > > >"DalePres" <don-t-spa-m-me@lea-ve-me-a-lone--.com> wrote in message >news:O39xgU9DFHA.732@TK2MSFTNGP12.phx.gbl... >> How are you creating your literals? In my tests of your problem, I found >> that Literals created in the aspx file as <asp:LITERAL> were not available >> in code even if I made sure that they were declared and instantiated in my >> codebehind. >> >> In order to get the Literals to work, I had to create them, instantiate >> them, and them to Page.Controls from within my codebehind. Done that way, >> I was able to access the Literal and manipulate its properties. >> >> >> "Islam Elkhayat" <islamegy@yahoo.com> wrote in message >> news:OAaOtI9DFHA.3244@TK2MSFTNGP15.phx.gbl... >>> It didn't throw Exception but also didn't work >>> if statment always false... so i always go to the else!! >>> >>> How can i make it work?? >>> >> >> >
- Next message: DalePres: "Re: loop througth Literials using foreach!!"
- Previous message: DalePres: "Re: loop througth Literials using foreach!!"
- In reply to: Islam Elkhayat: "Re: loop througth Literials using foreach!!"
- Next in thread: Patrick Olurotimi Ige: "Re: loop througth Literials using foreach!!"
- Reply: Patrick Olurotimi Ige: "Re: loop througth Literials using foreach!!"
- Reply: Islam Elkhayat: "Re: loop througth Literials using foreach!!"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|