Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1101
  • Last Modified:

MVVM Pattern in asp.net web application

Hi

I have a web application in which I want to implement MVVM pattern. I want to know if there any sample code that will clearly mention what all steps I need to execute to implement it.


Apart from that I want to know if there is any dll that need to be refered.

Kindly advice

Regards
Karan Gupta
0
KaranGupta
Asked:
KaranGupta
  • 6
  • 4
  • 2
5 Solutions
 
Gautham JanardhanCommented:
0
 
DhaestCommented:
0
 
KaranGuptaAuthor Commented:
Hi

I am trying to implement the code(please check the code section).  I am getting the compile time error

1. INotifyPropertyChanged is not defined.
2. Application is not declared
3. Type PropertyChangedEventHandler is not defined.

Is there any namespace that I am missing,

Regards
Karan Gupta
Imports Microsoft.VisualBasic

Public Class ViewModelBase
    Inherits INotifyPropertyChanged

    Protected Sub OnNotifyPropertyChanged(ByVal p As String)
        RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(p))
    End Sub

    Public ReadOnly Property IsDesignTime() As Boolean
        Get
            Return (Application.Current Is Nothing) OrElse (Application.Current.[GetType]() = GetType(Application))
        End Get
    End Property

#Region "INotifyPropertyChanged Members"
    Public Event PropertyChanged As PropertyChangedEventHandler
#End Region


End Class

Open in new window

0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
KaranGuptaAuthor Commented:
Hi

I have included System.ComponentModel namespace but still I am getting the same error. Please check the code attached.


Regards
Karan Gupta

Imports Microsoft.VisualBasic
Imports System.ComponentModel


Public Class ViewModelBase
    Inherits INotifyPropertyChanged

    Protected Sub OnNotifyPropertyChanged(ByVal p As String)
        RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(p))
    End Sub

    Public ReadOnly Property IsDesignTime() As Boolean
        Get
            Return (Application.Current Is Nothing) OrElse (Application.Current.[GetType]() = GetType(Application))
        End Get
    End Property

#Region "INotifyPropertyChanged Members"
    Public Event PropertyChanged As PropertyChangedEventHandler
#End Region


End Class

Open in new window

0
 
DhaestCommented:
0
 
KaranGuptaAuthor Commented:
Hi

As the tutorial given in

http://weblogs.asp.net/dwahlin/archive/2009/12/08/getting-started-with-the-mvvm-pattern-in-silverlight-applications.aspx

there has to be View, Model and View Model that is what MVVM pattern is all about. If I am making a contact us page then I have a textbox. In the view i.e. .aspx page I will put all the UI part. In the view model it should be properties . When it comes to Business logic out all the logic in the Model.

I have some queries

1. Is what I have written is correct?
2. View model should be inherited from ViewModelBase class. Am I right(Please check code section)?
3. Is the model class should be inherited from some class?

Kindly advice

Regards
Karan Gupta
Imports System.ComponentModel

Public Class ViewModelBase
    Implements INotifyPropertyChanged

    Public Event PropertyChanged As PropertyChangedEventHandler _
        Implements INotifyPropertyChanged.PropertyChanged

    Private Sub NotifyPropertyChanged(ByVal info As String)
        RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(info))
    End Sub
End Class

Open in new window

0
 
KaranGuptaAuthor Commented:
Hi

Can we application MVVM pattern in simple asp.net application without using silverlight?


Regards
Karan Gupta
0
 
KaranGuptaAuthor Commented:
Hi

Any updates?

Regards
Karan Gupta
0
 
DhaestCommented:
0
 
Gautham JanardhanCommented:
MVVM was designed keeping Silver light /  WPF in mind so i don't think you will be able to utilize it in Asp.net. You may either look into MVP as Dhaest suggested  or better go for MVC
0
 
KaranGuptaAuthor Commented:
Query resolved
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 6
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now