Ironpython also plays Ajax!

Source: Internet
Author: User
In the ironpython project (or a mixed project with C #, see my previous post), you can use anthem. Net to easily implement Ajax functions.

Here is a simple example: on the page, we put an anthem text box and a button control. When you click a button, use Asynchronous callback to change the value in the text box.
CodeSimple:

Page ajax1.aspx:

<% @ Page Language = " Ironpython " Codefile = " Ajax1.aspx. py "   %>
<% @ Register assembly = " Anthem " Tagprefix = " Anthem " Namespace = " Anthem "   %>

<!Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

< Html Xmlns = "Http://www.w3.org/1999/xhtml"   >
< Head Runat = "Server" >
< Title > Ironpython Ajax example </ Title >
</ Head >
< Body >
< Form ID = "Form1" Runat = "Server" >
< Div >
< Anthem: textbox ID = "Txt1" Runat = "Server"   />
< Anthem: button ID = "Btn1" Runat = "Server" Text = "Test" Autocallback = "True" Precallbackfunction = "" Onclick = "Btn1_click"   />
</ Div >
</ Form >
</ Body >
</ Html >

Background code ajax1.aspx. py:

Def Btn1_click (sender, argS ):
Txt1.text = U " Chinese "
Txt1.updateaftercallback = True

Demo effect:

Although the example is very simple, it can be seen that the implementation of ironpython for ASP. NET has unlimited application possibilities.

Note that ironpython'sSource codeIf the string contains Chinese characters, it must be expressed in the u'string' format. Otherwise, it will fail. And the code file needs to be saved in UTF-8 format.

Related Article

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.