Question

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";
Était-ce utile?

La 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.

Autres conseils

You could embed the script into the assembly containing the control which the developers will use without the need to declare it in their own assembly. Microsoft did the same thing with the System.Web assembly containing their base controls, so all that a developer needs is reference this assembly. and place the control onto the WebForm.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top