ASP.NET WebForms MVVM
Implementation of MVVM pattern for ASP.NET WebForms

Sample:
<%@ Page Language="C#" Inherits="Nomad.ASPMVVM.PageView" ViewModel="ASP.MVVM.ViewModel.TesteViewModel" %>

<%@ Import Namespace="Nomad.ASPMVVM" %>

<!DOCTYPE html>

<script runat="server">
private BindingProperty ValorProperty = new BindingProperty { Property = "Text", Path = "Valor" };
private BindingProperty ResultadoProperty = new BindingProperty { Property = "Text", Path = "Resultado", Format = "{0:#,##0.00}" };
private BindingProperty OperacoesProperty = new BindingProperty { Property = "DataSource", Path = "Operacoes", NeedsBind = true };
private BindingProperty OperacaoSelecionadaProperty = new BindingProperty { Property = "SelectedValue", Path = "OperacaoSelecionada" };

private BindingProperty CalcularCommand = new BindingProperty { Path = "Calcular", IsCommand = true };
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager runat="server" />
<asp:UpdatePanel runat="server">
<ContentTemplate>
<p>
<asp:TextBox runat="server" Binding='<%# Eval(ValorProperty) %>' />
<asp:DropDownList runat="server" Binding='<%# Eval(OperacoesProperty, OperacaoSelecionadaProperty) %>' />
<asp:Button Text="Calcular" runat="server" Binding='<%# Eval(CalcularCommand) %>' />
</p>
<p>
<asp:Label runat="server" Binding='<%# Eval(ResultadoProperty) %>' />
</p>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>

Last edited Sep 25, 2012 at 1:56 PM by ruisantos, version 3