locked
LocalResources and DB RRS feed

  • Question

  • User-379741155 posted

     

    Hello all,

    I  have project to work with a web application to retrieve local and global resources from a DB. This project also replace the default tool of VS to create the local resources and when you use the Generate Local Resource tool adds all the resources of the page to the DB.

    You may know that this tool (Generate Local Resource) creates a group of resources for each control (for the label control, Text and Tooltip, for example) and I would like to add one property to be created in the DB when this tool is used. What I would like to get is that this tool to generate the ImageUrl resource for Image controls.

    Do you know How I can get this?

     
    Thank you!


     

    Thursday, November 8, 2007 2:28 AM

Answers

  • User1642585364 posted

    For runtime resource support, you need a class which descends from [url=http://msdn.microsoft.com/en-us/library/system.web.compilation.resourceproviderfactory.aspx]ResourceProviderFactory[/url] and appropriate [url=http://msdn.microsoft.com/en-us/library/system.web.compilation.iresourceprovider.aspx]IResourceProvider[/url] implementations for the local and global resources.  I recall finding some sample codes for using a database as a backend for your resources, but I didn't save the links.  Just use search keywords like 'sql resource provider asp.net' or something similar and it should be fairly easy to find.

    For the design time support (i.e. Generate Local Resource), you need a class that descends from [url=http://msdn.microsoft.com/en-us/library/system.web.ui.design.designtimeresourceproviderfactory.aspx]DesignTimeResourceProviderFactory[/url] and implementations for the corresponding IResourceProvider (for previewing I think) and [url=http://msdn.microsoft.com/en-us/library/system.web.ui.design.idesigntimeresourcewriter.aspx]IDesignTimeResourceWriter[/url].  I couldn't find any database samples for this when I was trying to figure it out, but [url=http://www.leftslipper.com/ShowFaq.aspx?FaqId=9]here[/url] is a sample one using Access that you might be able to port.  I didn't have enough time to try that msyelf.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, November 8, 2007 1:15 PM

All replies

  • User1642585364 posted

    For runtime resource support, you need a class which descends from [url=http://msdn.microsoft.com/en-us/library/system.web.compilation.resourceproviderfactory.aspx]ResourceProviderFactory[/url] and appropriate [url=http://msdn.microsoft.com/en-us/library/system.web.compilation.iresourceprovider.aspx]IResourceProvider[/url] implementations for the local and global resources.  I recall finding some sample codes for using a database as a backend for your resources, but I didn't save the links.  Just use search keywords like 'sql resource provider asp.net' or something similar and it should be fairly easy to find.

    For the design time support (i.e. Generate Local Resource), you need a class that descends from [url=http://msdn.microsoft.com/en-us/library/system.web.ui.design.designtimeresourceproviderfactory.aspx]DesignTimeResourceProviderFactory[/url] and implementations for the corresponding IResourceProvider (for previewing I think) and [url=http://msdn.microsoft.com/en-us/library/system.web.ui.design.idesigntimeresourcewriter.aspx]IDesignTimeResourceWriter[/url].  I couldn't find any database samples for this when I was trying to figure it out, but [url=http://www.leftslipper.com/ShowFaq.aspx?FaqId=9]here[/url] is a sample one using Access that you might be able to port.  I didn't have enough time to try that msyelf.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, November 8, 2007 1:15 PM
  • User-379741155 posted

    The proyect we use has a class that implements IDesignTimeResourceWriter that has the method AddResource(string name , object value) that implements System.Resources.IResourceWriter.AddResource, that save the data in a ListDictionary used, some steps later, to create the resources in the DB. This method is called by VS, which send the resource name (e.g. Label1.Text) and the value, and I am again at the beginning.

    There is another method  System.Web.UI.Design.IDesignTimeResourceWriter.CreateResourceKey, as far I have tested, it is not called anytime.

    Thank you, your indications has given me where to look for. 

     


    Friday, November 9, 2007 5:57 AM
  • User-823627051 posted

    IDesignTimeResourceWriter.CreateResourceKey is called when a meta:resourcekey havn't been added on the control yet.

    Thursday, April 29, 2010 11:24 AM