<%@ 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 例子</title>
</head>
<body>
    
<form id="form1" runat="server">
    
<div>
      
<anthem:TextBox ID="txt1" runat="server" />
      
<anthem:Button ID="btn1" runat="server" Text="测试" AutoCallBack="true" PreCallBackFunction="" OnClick="btn1_Click" />      
    
</div>
    
</form>
</body>
</html>

后台代码 ajax1.aspx.py:

def btn1_Click(sender, args):
    txt1.Text 
= u"中国人"
    txt1.UpdateAfterCallBack 
= True

演示效果:

IronPython+Anthem.Net也玩 Ajax!

例子虽然非常简单,但在目前来看,可以表明 IronPython for ASP.NET 的实现有着无限的应用可能 :)

上述例子中需要注意的是,IronPython 的源代码中字符串如果包含中文,则需要用 u'字符串' 的方式来表示,否则会失败。并且这个代码文件需要保存为 UTF-8 格式。

相关文章:

  • 2021-09-15
  • 2022-12-23
  • 2021-10-25
  • 2022-03-02
  • 2022-12-23
  • 2022-02-22
  • 2021-10-08
猜你喜欢
  • 2022-02-20
  • 2021-11-12
  • 2022-12-23
  • 2021-06-04
  • 2021-08-13
  • 2022-12-23
  • 2022-02-03
相关资源
相似解决方案