Re: loop througth Literials using foreach!!

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Scott Allen (scott_at_nospam.odetocode.com)
Date: 02/11/05


Date: Fri, 11 Feb 2005 16:39:23 -0500

How do you currently load the resource manager? Can't you expose the
resource manager as a property of the form, or grab a reference from a
static helper property / method?

--
Scott
http://www.OdeToCode.com/blogs/scott/
On Fri, 11 Feb 2005 20:37:27 +0200, "Islam Elkhayat"
<islamegy@yahoo.com> wrote:
>I tried to create new control drived from Literial...
>I add the Key property and in the render method i Can't assign the base.Text 
>to the ResourceManager Getstring() of my main application form....
>Do i have to load my assembly & resouce manager in the new control??
>
>
>"Scott Allen" <scott@nospam.odetocode.com> wrote in message 
>news:fm2o019au8if3roq6mrrsgms0mu4droi5q@4ax.com...
>> 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??
>>>>>
>>>>
>>>>
>>>
>> 
>


Relevant Pages

  • Re: loop througth Literials using foreach!!
    ... If there is a literal control on the page, ... Perhaps you meant you didn't want to declare a ... >I want to loop throught literials so i don't use ... >> In order to get the Literals to work, I had to create them, instantiate ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: loop througth Literials using foreach!!
    ... If you are inside of BeginRequest, then stick a reference to the ... resource manager into Context.Items, i.e: ... Later, during processing of the page and or control, you can pull out ... >>>>>I want to loop throught literials so i don't use ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Null pointer exception for events in usercontrols (C#)
    ... > I'm writing user controls with custom events. ... > custom control and add some text boxes, labels, buttons etc... ... > public delegate void PirEventHandler ... The fact is that I never instantiate this object as I ...
    (microsoft.public.dotnet.languages.csharp)
  • CCW/,NET UserControl lifetime question
    ... A CCW is created for IE to instantiate and call methods on this user ... control and every re-rendering of that page (due to user clicking the ... This should further release the sole reference to the .NET usercontrol ...
    (microsoft.public.dotnet.framework.interop)
  • Re: ActiveX Control will not instantiate
    ... ISetSite ... why IE will not instantiate an ActiveX control? ... I have written a custom ActiveX control in Visual Basic 6. ...
    (microsoft.public.windows.inetexplorer.ie6.browser)