Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6342981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:20:53+00:00 2026-05-24T20:20:53+00:00

I have come from WPF (MVVM) background and trying to shift to MVC 2.

  • 0

I have come from WPF (MVVM) background and trying to shift to MVC 2. Is there any pattern in MVC2 where you can use Commanding/Command buttons like <input> which you use to submit the form so that you can hide/disable when you try to Render the View.

In MVVM world, your commands could implement ICommand interface, and it had CanExecute method which was quite useful. I was wondering if there is anything similar in ASP MVC 2 ?

The only way I can think of, is to do it in the View, so that I can check the flag on ViewModel (CanSave) and depending on that show/hide the <input> tag.

Basically I want to have 2 version of the website running, one in Read-Only mode and the other Editing mode.

Let me know if you need any clarification.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T20:20:54+00:00Added an answer on May 24, 2026 at 8:20 pm

    ASP.NET MVC does not feature the notion of ‘controls’, as are found in classic ASP.NET and WPF. The foundational blocks of ASP.NET MVC are HTML elements, like <input>, <button> et cetera. Naturally, these don’t offer the functionality you’re looking for (i.e. Implementation of the ICommand Interface).

    The scenario that you’re looking at (i.e. two modes of your form) can be (and arguably should be) dealt with at the View level. You’re already facing the right direction: have a ‘CanSave’ property on your Model, and use this in the View to determine what is generated.

    Example:

    <% if (Model.CanSave)
        { %>
            <p>First Name: <%= Html.TextBox("firstname", Model.firstname) %> </p>
    <%  }
        else
        { %>
            <p>First Name: <%=Model.firstname %></p>
    <%  } %>
    

    You’ll probably want to check out the DisplayTemplates and EditorTemplates… very handy for this scenario. Brad Wilson does a good job here.

    It will help you move to this:

    <%= (Model.CanSave) ? Html.EditorFor(x => x.firstname) : Html.DisplayFor(x => x.firstname) %>
    

    …which makes your View clean and nice.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to WPF and come from a WinForms background and have a fairly
I am a .NET developer now and have come from Foxpro /VB6/COM background. Over
I come from a Java background and have been using C# for the last
I come from Java Background and so used to Debugging using Eclipse but have
I have an ActiveRecord model whose fields mostly come from the database. There are
I come from classes object orientation languages and recently I have been learning those
I come from the iPhone development world but have never developed desktop applications. Now
I have some colors that seem to come from a Delphi TColor variable (e.g
I have a report where the fields come from data pulled from a SQL
I have taken over some code from a previous developer and have come across

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.