To compile a JS file into a dynamic-link library (DLL) file

Source: Internet
Author: User
Tags domain name
js| Compilation | news | links

1. Add a JScript file to your project

Script_1.js-----
function DoClick1 ()
{
Alert ("Ok1_wufeng");
}
Script_2.js-----
function DoClick2 ()
{
Alert ("OK2");
}

2. In Solution Explorer, right-click the properties of Script_1.js and Script_2.js and set the Build Action property in advanced to "embedded resources."

3. Add the following line to the AssemblyInfo.cs file: (Note the domain name WF.) ClientScriptResourceLabel)

[Assembly:System.Web.UI.WebResource ("WF.") ClientScriptResourceLabel.script_1.js "," Application/x-javascript ")]
[Assembly:System.Web.UI.WebResource ("WF.") ClientScriptResourceLabel.script_2.js "," Application/x-javascript ")]

4. Add a class to the project, instance:

Using System;
Using System.Drawing;
Using System.Web.UI;
Using System.Web;
Using System.Globalization;

namespace WF. ClientScriptResourceLabel
{
public class ClientScriptResourceLabel:System.Web.UI.WebControls.WebControl
{
Invoke Script Resource
protected override void OnPreRender (EventArgs e)
{
if (this. Page!= null)
{
This. Page.ClientScript.RegisterClientScriptResource (typeof (ClientScriptResourceLabel), "WF." ClientScriptResourceLabel.script_1.js ");
This. Page.ClientScript.RegisterClientScriptResource (typeof (ClientScriptResourceLabel), "WF." ClientScriptResourceLabel.script_2.js ");
}
Base. OnPreRender (e);
}

<summary>
Methods to render the control rendercontents
</summary>
protected override void RenderContents (HtmlTextWriter output)
{
Output. AddAttribute ("id", "1");
Output. AddAttribute ("Type", "checkbox");
Output. AddAttribute ("Value", "Test 1");
Output. AddAttribute ("onclick", "javascript:doclick1 ();");
Output. RenderBeginTag (Htmltextwritertag.input);
Output. RenderEndTag ();

Output. AddAttribute ("id", "2");
Output. AddAttribute ("Type", "checkbox");
Output. AddAttribute ("Value", "Test 2");
Output. AddAttribute ("onclick", "Javascript:doclick2 ();");
Output. RenderBeginTag (Htmltextwritertag.input);
Output. RenderEndTag ();

Base. RenderContents (output);
}
}
}



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.