To prevent javascript code theft, We can compile the js file into a dynamic link library (dll) file. The following creates a control to demonstrate this function.
1. Create a class library project named UpdateAnimate.
2. Add reference System. Web, System. Drawing, System. Web. Extensions to the Project
3. Add a Jscript file UpdatePanelAnimation. js to the project.
4. Add the following code to the file:
BorderAnimation = function(color) {this._color = color; } BorderAnimation.prototype = { animate: function(panelElement) { var s = panelElement.style; s.borderWidth = '2px'; s.borderColor = this._color; s.borderStyle = 'solid'; window.setTimeout( function() { { s.borderWidth = 0; } }, 500); } }
|
This short code contains a method for temporarily changing the UpdatePanel control style.
5. In Solution Explorer, right-click UpdatePanelAnimation. js and set the "generate operation" attribute in advanced to "embedded resource ".
6. Add a CustomControl class to the Project
7. Code in the replacement class:
8. Add the following lines to the AssemblyInfo. cs file:
[assembly: System.Web.UI.WebResource( "UpdateAnimate.UpdatePanelAnimation.js", "application/x-javascript")]
|