MVVM in asp.net? RRS feed

  • Question

  • I want to know whether MVVM can be used in asp.net webforms applications.I have googled about it and found http://aspnetmvvm.codeplex.com/

    But in the above link, MVVM is used in asp.net MVC but not in asp.net webforms.

    Please let me know if MVVM can be implemented in asp.net webforms applications.


    Tuesday, October 23, 2012 1:54 AM


All replies

  • Microsoft send this MVVM patterns and Practices for only Silverlight and WPF so if you want to integrate this in asp.net then you have to use the MVC or say MVP in you application

    Tuesday, October 23, 2012 2:36 AM
  • Thanks for your reply.I also found another link which enables two way data binding in asp.net similar to wpf therby enabling mvvm.Please refer this link http://www.codeproject.com/Articles/146078/WPF-Two-way-Databinding-in-ASP-NET-Enabling-MVVM

    So since according to you,MVVM doesn't support asp.net,can you please explain what actually is shown in the above link ,in the architecture level so that I can finalize on this.

    • Proposed as answer by The Z Man Friday, February 7, 2014 8:57 AM
    Tuesday, October 23, 2012 4:44 AM
  • Please have a look at this demo. It includes using MVVM with a stack of tools/technologies using ASP.NET.




    Wednesday, October 24, 2012 1:20 AM
  • The reason mvvm works for silverlight  is really simple(the xaml template)


    You can apply this for asp.net by using Javascript(knockout template)  http://magedfarag.wordpress.com/2012/10/13/asp-net-web-api-knockout-test-drive/

    By the way if you are interested you can do this in winRT(desktop) which uses wpf, silverlight and xaml        

    Wednesday, October 24, 2012 7:53 PM
  • Thanks all for your replies.

    I have gone through all of the above references.But they use javascript libraries.And many of them are very complicated compared to implementing mvvm in silverlight or wpf.And also they talk about building client-side asp.net applications using MVVM thereby using javscript libraries.But I want to develop a server side asp.net web application which follows mvvm pattern.

    So does MVVM really support ASP.NET webforms applications directly without any third party libraries and javascript? 

    Plz excuse me if I have gone wrong anywhere.


    Thursday, October 25, 2012 2:48 AM
  • So does MVVM really support ASP.NET webforms applications directly without any third party libraries and javascript? 

    Also suggest you ask here about webform.


    Thursday, October 25, 2012 10:14 PM
  • Although I have not done this - but putting forward a concept for implementing MVVM in ASP.Net Web Forms (I am a person who likes to do own things :-))

    1. Model --> Are my XML documents 

    2. VM --> we have client side JavaScript / JQuery files which does the business of Binding XML to UI and creating XML from UI.

    3. View --> ASPX / Html pages wih All UI code

    4. VM-Server --> C# classes (And not code Behind files) that  does conversion between XML objects and Data (DB)  - and needless to mention applies all Business Logic

    5. Code behind files are just pass-throughs to call appropriate VM on the server based on user interaction.

    Isn't it MVVM - we can test individual component (server side and client side), we have done this many time as well.

     - Sepration of concern is done

     - one of the main pain point is code behind files make difficult to test ASPX page in isolation

     - HTML code can also be tested without having to worry about connectivity with server - by creating standalone HTML, JavaScropt and XML

    Friday, March 15, 2013 1:29 AM
  • http://visualstudiogallery.msdn.microsoft.com/e63e6b76-6e15-470b-8bbe-2c3185b05635

    webforms runat="server" control binding expression extensions.

    Sunday, April 21, 2013 5:01 PM