Sunday, January 20, 2008

ASP.NET - IronPython

It's now possible to use IronPython in Visual Web Developpement Express Edition 2008.
If you are wondering does it worth to switch to IronPython.
Look at this server side part, and compare it with the traditionals languages used

Server Side:

def Page_Load(sender, e):
pass

def onClickButton1(s,e):
color = result.InnerHtml = TextBox1.Text
result.Style.set_Value("background-color:%s;"%color)

def Menu1_MenuItemClick(s,e):
result.Style.set_Value("background-color:red")
choice = Menu1.SelectedValue
result.InnerHtml = choice


Client Part:

<%@ Page Language="IronPython" CodeFile="Default.aspx.py" Inherits="Microsoft.Web.Scripting.UI.ScriptPage" %>

<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Menu ID="Menu1" runat="server" Orientation="Horizontal" OnMenuItemClick="Menu1_MenuItemClick">
<Items>
<asp:MenuItem Text="Fichier" Value="Fichier"></asp:MenuItem>
<asp:MenuItem Text="About" Value="About"></asp:MenuItem>
</Items>
</asp:Menu>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="onClickButton1" />
<div id="result" runat="server">
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>

No comments:

Post a Comment