Wednesday, September 5, 2007

Embed your javascript file into single DLL

If you want your javascript hidden or secure inside the dll...

Please see this step... to embed your javascript file (*.js) into your dll.

  • Go to the property of the javascript file (Right Click in *.js file)
  • Change Build Action to Embeded Resource (Default is content)

  • Go To AssemblyInfo.vb (Turn on Show All file to see that file)
  • Add <AssemblyL System.Web.
    UI.WebResource("YourNameSpace.YourJSName.js", "application/x-Javascript")>

  • Register to Page control.Page.ClientScript.RegisterClientScriptResource
    (typeOf(yourClassName),"YourNameSpace.YourJSName.js");
OR if available
  • Register to AjaxToolkit.ScriptManager using Reflection

    System.Type
    _ScriptManager = Type.GetType
    ("System.Web.UI.ScriptManager , System.Web.Extension");

    if (_ScriptManager == null)
    throw new Exception(" Use... the other register above");

    System.Reflection.MethodInfo
    _RegisterClientScriptResourceMethod =
    _ScriptManager.GetMethod("RegisterClientScriptResource",new Type()
    {typeof(System.Web.UI.Control), typeof(Type), typeof(System.String)} );


    _RegisterClientScriptResourceMethod.Invoke(Nothing, new Object()
    (this,typeOf(yourClassName),"YourNameSpace.YourJSName.js");

No comments: