Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to access internal methods

How to access internal methods

Scheduled Pinned Locked Moved C#
questiondesigntutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Andre Vianna
    wrote on last edited by
    #1

    I'm trying to build a custom control and I'd like to access some funcionalities of ClientScriptManager defined as internal on System.Web.UI Here is a sample code:

    namespace MyWebControls {
    public class MyGridView : System.Web.UI.WebControl.GridView {
    ...
    protected internal virtual MyMethod(object pLiteral) {
    ...
    var vLiteralName = ClientScriptManager.GetScriptLiteral(pLiteral);
    ...
    }
    ...
    }
    }

    I've tryied also:

    		var vLiteralName = this.Page.ClientScript.GetScriptLiteral(pLiteral);
    

    The functionality exists but is defined as internal. How can I access it? Maybe some property on the Assembly. Change the namespace. I've tryied several things. Please give me some light. Thanks.

    H S 2 Replies Last reply
    0
    • A Andre Vianna

      I'm trying to build a custom control and I'd like to access some funcionalities of ClientScriptManager defined as internal on System.Web.UI Here is a sample code:

      namespace MyWebControls {
      public class MyGridView : System.Web.UI.WebControl.GridView {
      ...
      protected internal virtual MyMethod(object pLiteral) {
      ...
      var vLiteralName = ClientScriptManager.GetScriptLiteral(pLiteral);
      ...
      }
      ...
      }
      }

      I've tryied also:

      		var vLiteralName = this.Page.ClientScript.GetScriptLiteral(pLiteral);
      

      The functionality exists but is defined as internal. How can I access it? Maybe some property on the Assembly. Change the namespace. I've tryied several things. Please give me some light. Thanks.

      H Offline
      H Offline
      Heywood
      wrote on last edited by
      #2

      If the function you're trying to access is marked internal, it's only accessible from within the same module: From HELP: The internal keyword is an access modifier for types and type members. Internal types or members are accessible only within files in the same assembly. A common use of internal access is in component-based development because it enables a group of components to cooperate in a private manner without being exposed to the rest of the application code. For example, a framework for building graphical user interfaces could provide Control and Form classes that cooperate using members with internal access. Since these members are internal, they are not exposed to code that is using the framework. It is an error to reference a type or a member with internal access outside the assembly within which it was defined.

      1 Reply Last reply
      0
      • A Andre Vianna

        I'm trying to build a custom control and I'd like to access some funcionalities of ClientScriptManager defined as internal on System.Web.UI Here is a sample code:

        namespace MyWebControls {
        public class MyGridView : System.Web.UI.WebControl.GridView {
        ...
        protected internal virtual MyMethod(object pLiteral) {
        ...
        var vLiteralName = ClientScriptManager.GetScriptLiteral(pLiteral);
        ...
        }
        ...
        }
        }

        I've tryied also:

        		var vLiteralName = this.Page.ClientScript.GetScriptLiteral(pLiteral);
        

        The functionality exists but is defined as internal. How can I access it? Maybe some property on the Assembly. Change the namespace. I've tryied several things. Please give me some light. Thanks.

        S Offline
        S Offline
        S Senthil Kumar
        wrote on last edited by
        #3

        If you're really desperate, you can use Reflection[^].

        Regards Senthil [MVP - Visual C#] _____________________________ My Home Page |My Blog | My Articles | My Flickr | WinMacro

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups