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.