I am working on a project where I have to do some considerable customizations around localization. Specifically the product needs to handle 4 different languages from PickLists, Groups, DependencyLookups, and more. Today I was implementing a solution around dependency lookups and could not get the lookup to change based on my language settings. What I was doing was changing the PreFilter properties to point to an extended field on my ACI table. I tried various things with no success. I decided to dig into the controls code and see if there was something that would lead me to a solution.

In the code I got my Ah Ha moment as I could see that some filter state was being stored in the HttpCache however it was never being cleared, nor was there a way on the control to invoke a clear action. Though the control did not expose an invalidate method the solution was quite simple once the issue was discovered.

Simply call

HttpContext.Current.Cache.Remove(dpeLookup.ClientId);

This will clear the filters from the cache and reload them correctly.

Mark

3 Comments

  1. Where exactly do you place this http.context code for a custom form…..obviously not in the ascs.cs file…..

    And when\how do you change a PreFilter in the Dependency Lookup? you can’t have a code block in the ascx file, correct?

    Thanks!

  2. What do you mean ‘Obviously not in the ascx.cs file’. Depending on how you update the DPL control you will call the cache clear code. If you write an CSharp code snippet then you will do it in the script, however if you do it in a obsolete method it will be generated in the ascx.cs file and IMHO is absolutely fine. I actually believe for the most part the CSharp snippets are overkill and add a little overhead to the debug situation. Think of it this way. In AA you can stubb your method to generate out in the smartpart itself, you can then go to VS and run/test and alter as needed porting back your code when you are happy. You can do the same thing with the Code snippets however you have to include the assembly to your solution and if you compile the project in AA and are using a newer version of VS (me 2010) you need to go back and change project properties to point to the correct framework version. Not a big deal but definately a kink in the flow of things.

  3. Agree CodeSnippets are an unwanted overhead! Never use them, much easier right in the ascx.

    Hey Mark, hows it going?

    So am I right in thinking this line:

    HttpContext.Current.Cache.Remove(dpeLookup.ClientId);

    Clears the LookupPreFilters on a lookup (so you can reset them to something else in code)? I know they cache to the point that you have to logout to see any change to them.

    If it does you may have saved me a lot of time in working out how to do an “In” in a SeedProperty and SeedValue!

    Thanks,
    Nick

Leave a Reply