Axial: Use the. NET language to write JavaScript code

Source: Internet
Author: User

Axial is an open-source project on codeplex. We can use it to implement Javascript in C # Or VB. NET mode, and then it will automatically output the corresponding JavaScript to the client. Some form controls can be used for input verification, some JS effects, and Ajax. Axial now encapsulates jquery, so that we can use C # Or VB. NET to use jquery.

Axial contains several server controls:

  • Wfserverscript
  • Wfscript
  • Wfvalidator
  • Wfstartupscript
  • Wfclass
  • Canvas
  • Wfscriptbutton

Axial is easy to use:

1. Add an axial. dll reference and add the axial control to the control toolbox.

2. Write the related Javascript. Net Method in the background. The method must be public.

 

Using Axial;
Using Axial. jquery;
Using Axial. Dom;

Namespace axialweb
{
Public partial class jquerytest: system. Web. UI. Page
{
Protected void htmlthedivs (){
Jquery. jquery ("Div. Empty" ).html ("in a div ");
Jquery. Get ("viaajax.txt", "", (response) =>{ jquery. jquery ("Div. Empty: First" ).html (string) response );});
Jquery. jquery ("Div. notempty" 2.16.children().html ("when two divs love each other very much ");
Jquery. jquery ("Div. notempty" ).children().css ("padding", "3px ");
Jquery. jquery ("Div. notempty"). Children (). Each (alertpadding );
}

Protected void alertpadding (){
Window.alert(jquery.this.css ("padding "));
}
}
}

 

3. Place an axial control on the ASPX page at the front end and set the methodname attribute.

 

<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> jquery test </title>
<SCRIPT type = "text/JavaScript" src = "jquery-1.2.3.min.js"> </SCRIPT>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Div class = "empty" style = "border: 1px solid red;"> </div>
<Div class = "empty" style = "border: 1px solid blue;"> </div>
<Div class = "notempty" style = "border: 1px solid green;">
<Div style = "border: 1px solid purple;"> </div>
</Div>

<Asp: button runat = "server" id = "btnrun" text = "run" onclientclick = "htmlthedivs (); Return false;"/>
<Axial: wfscript runat = "server" id = "wfshtd" methodname = "htmlthedivs"/>
</Form>
</Body>
</Html>

 

For detailed use of axial, please download the source code from codeplex, which contains detailed code examples.

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.