Search code examples
asp.net.netassembliesscriptcontrol

Assembly embedded resources


Does the row below is required in AssemblyInfo.cs if i want to add an embedded script to the assembly with my custom usercontrol? Does exists any alternative to this?

[assembly: System.Web.UI.WebResource("Modal.js", "text/javascript")]

I'm developing custom IScriptControl that has JS. Both, CS and JS of the control are in same assembly. In the control, i have a lines:

ScriptReference reference = new ScriptReference();
reference.Assembly = "Modal";
reference.Name = "Modal.js";

Solution

  • I found a solution.

    [assembly: System.Web.UI.WebResource("Modal.js", "text/javascript")]
    

    can be written or in AssemblyInfo.cs or above of namespace

    [assembly: System.Web.UI.WebResource("Modal.js", "text/javascript")]
    namespace Core.Web.UI.ScriptControls
    {
    

    Now it easier for developers to add new controls.