Tuesday, July 28, 2009

Embedding JavaScript files in your custom controls

Following steps are used in order to embed the JavaScript file along with the custom control’s dll as an embedded resource:
1. Add the JavaScript file into the project.
2. Right click on the JavaScript file and click on properties. In the properties window change the Build Action Property into the Embedded Resource [default is Content]
3. Modify the AssemblyInfo.cs by adding the following code
[assembly: System.Web.UI.WebResource("NameSpace.FolderName.FileName.js", "text/javascript", PerformSubstitution = true)]
4. Build the project and JavaScript file will be embedded along with the custom controls dll.

1 comment: