How to "Imports Resources" into compiled custom controls?

Ask a Question related to ASP.NET Building Controls, Design and Development.

  1. #1

    Default How to "Imports Resources" into compiled custom controls?

    Hi,

    I am building a custom control for a Web Application in ASP.NET 2.0 that
    makes use of the name space "Resources" for localization
    (app_globalresources) by adding this to the top of the customcontrol.vb file
    in the app_code directory:

    Imports Resources

    However, when I move the file to a project of its own, the reference to
    Resources cannot work anymore for understandable reasons since resources is
    not part of the project. How do I make use of the global resource of the web
    application for the custom control?

    Do I have to create a resource for the custom control? I want to keep
    localization in one place though.

    Do I have to leave the custom control in App_Code if I want localization to
    be in one place?

    Please let me know if it is possible.
    Samuel Guest

  2. Similar Questions and Discussions

    1. Acrobat Pro does not open because : "language resources"
      Suddenly (I think after an update about a month ago) Acrobat Pro 6.0.2 refuses to open. I get this message : «The currently selected language...
    2. changes to .as files not "compiled"
      Upon making modifications to .as files, I've noticed when testing movies within the IDE (ctrl-ENTER) that my changes are not always applied. I use...
    3. Impatient Newbie Question: "Self-Compiled..."???
      "dhtapp" <dhtapp@cox.net> wrote: If you're referring to:- http://www.ruby-talk.org/78848 -----------------------------------------------------...
    4. "required resources" problem
      I only get this error when attempting to work with picture packages. It was discussed on a different thread and I thought we had it resolved, but it...
    5. "sendmail_from" not set in php.ini or custom "From:" header missing
      Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Lines: 14 Message-ID:...
  3. #2

    Default RE: How to "Imports Resources" into compiled custom controls?

    Thank you for posting .

    From your description, you're developing some custom ASP.NET web control,
    and the webcontrol will use some resources in the ASP.NET application's
    Global or Local Resource collection to perform some localization work.
    Howerver, you found it works well when put in the ASP.NET app's App_Code
    dir, when moved to a separate class library project, it stoped working,
    correct?

    Based on my understanding, as for the Global/Local Resources in ASP.NET
    application, they can be retrieved through declarative syntax or
    programmatic syntax. I think you are using the programmatic approach (the
    GetGlobalResourceObject and GetLocalResourceObject method). If this is
    the case, in your custom classlibrary project, if your custom control still
    want to utilize these methods, you need to reference System.Web.dll
    assembly, and then, use the HttpContext's static methods to reference the
    two methods, e.g.

    protected override void RenderContents(HtmlTextWriter output)
    {
    string value =HttpContext.GetGlobalResourceObject("strings",
    "key1").ToString();

    output.Write("<br/>Key1: " + value);
    output.Write(Text);
    }

    The following msdn document has also mentioned the HttpContext class for
    the two methods:

    [url]http://msdn2.microsoft.com/en-us/library/ms227982(VS.80).aspx[/url]

    Hope this helps.

    Regards,

    Steven Cheng
    Microsoft Online Community Support


    ==================================================

    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.

    ==================================================


    This posting is provided "AS IS" with no warranties, and confers no rights.



    Get Secure! [url]www.microsoft.com/security[/url]
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    Steven Cheng[MSFT] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139