Use ms ajax to compile js files into a dynamic link library (1)

Source: Internet
Author: User

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")]


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.