Model-View-ViewModel for ASP.NET Web Form Base.

has new Binding Expression in XHTML like WPF MVVM.

and a AJAX PageAdapter for Web Form hide all ViewState.



now MVVM add Code Maker to auto make ViewModel base class when build.

Behavior Control's mimicry.

about.



(1)

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>MVVM By ID</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <uc1:Hello ID="ViewModel" runat="server" />
        請輸入您的大名:<asp:TextBox ID="TextBox1" runat="server" Text="<%$ Binding: Name %>"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" Text="確定" OnClick="<%$ Binding: Button1_Click %>" /><br /><br />
        <asp:Label ID="Label1" runat="server" Text="<%$ Binding: Text %>"></asp:Label>
    </div>
    </form>
</body>
</html>

public partial class ViewModel_Hello3 : ViewModel.Base.Default3
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    public override void Button1_Click(object sender, EventArgs e)
    {
        if (Name != "")
        {
            Text = Name + ",您好。";
        }
        else
        {
            Text = "請輸入名字";
        }
        base.Button1_Click(sender, e);
    }
}

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Bind Control & Method</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <uc1:UserControl ID="UserControl1" runat="server" />
        <asp:Label ID="Label1" runat="server" Text='<%$ Binding : ID = UserControl1, GetText %>'></asp:Label>
        <asp:Panel ID="Panel1" runat="server" ToolTip="456">
            <asp:Label ID="Label2" runat="server" Text='<%$ Binding : Type = Panel, ToolTip %>'></asp:Label>
        </asp:Panel>
        <asp:TextBox ID="TextBox1" runat="server" AutoPostBack="true" Text="789"></asp:TextBox>
        <asp:Label ID="Label3" runat="server" Text='<%$ Binding : ID = TextBox1, Mode = OneWay , Text %>'></asp:Label>
        <%-- Mode => Default, OneWay, TwoWay --%>
    </div>
    </form>
</body>
</html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Behaviors</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="Button1" runat="server" Text="Button" />
        <asp:Label ID="Label1" runat="server" Text='<%# DateTime.Now.ToString() %>'></asp:Label>
        <uc1:CallMethodAction ID="CallMethodAction1" runat="server" TargetControlID="Label1"
            MethodName="DataBind">
            <uc2:EventTrigger ID="EventTrigger1" runat="server" SourceControlID="Button1" EventName="Click" />
        </uc1:CallMethodAction>
    </div>
    </form>
</body>
</html>

 

(2)

web.config

  <configSections>
     <section name="extensions" type="CachePage.ExtensionsConfigSection"/>
   </configSections>


  <extensions>
     <cachePageAdapter>
       <add path="/Default.aspx" updateTriggers="false"/>
       <add path="/Default2.aspx" updateTriggers="false"/>
       <add path="/Default3.aspx" updateTriggers="false"/>
     </cachePageAdapter>
   </extensions>



http://jurio-li.blogspot.com/

http://visualstudiogallery.msdn.microsoft.com/e63e6b76-6e15-470b-8bbe-2c3185b05635

Last edited Mar 13, 2012 at 9:36 AM by jurio_li, version 9