How to access internal methods
-
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.
-
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.
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.
-
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.
If you're really desperate, you can use Reflection[^].
Regards Senthil [MVP - Visual C#] _____________________________ My Home Page |My Blog | My Articles | My Flickr | WinMacro