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

  • Home
  • SEARCH
  • 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 96457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:49:04+00:00 2026-05-10T23:49:04+00:00

I am trying to learn ASP.NET MVC and I hit this problem: I have

  • 0

I am trying to learn ASP.NET MVC and I hit this problem: I have a ‘view product details’ form that I want to reuse as an add/edit form. (When you look at the product details, if you have the rights to do it an Edit link should appear; it should redisplay the same form, but with the textbox fields enabled this time.)

Right now the Details view looks something like this:

<% var product = ViewData.Model; %> <table>   <tr>     <td>Name</td>   </tr>   <tr>     <td><%= Html.TextBox('Name', product.Name, new { size = '50', disabled = 'disabled'})%></td>   </tr> 

Is there a way I could reuse it without putting too much logic in the view? For example, I will need to remove the disabled = 'disabled' part (but the size part needs to stay there), to put everything inside a form and so on.

If it can’t be done, that’s fine, I’m just trying not to repeat the same thing several times in case I need to change it (and I will).

  • 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. 2026-05-10T23:49:05+00:00Added an answer on May 10, 2026 at 11:49 pm

    You can always pass in a value indicating what mode you’re in or what privileges you have:

    ViewData.Model.CanEdit 

    So you might want to create a composite class for your model instead of just using Product

    public class ProductViewData {     public Product Product {get; set;}     public bool CanEdit {get; set;} } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to learn ASP.NET MVC, and I want to have menus highlighted on
I am trying to learn Asp.net Mvc so I am trying out this Tutorial.
I'm trying to learn ASP.NET MVC, so I did as test project this where
I have been trying to learn ASP.NET MVC 3 and things are going well
I am trying to learn mvc. I use Pluralsight training videos in this site(asp.net).
I am trying to learn ASP.net MVC 2 and I have created the DB
I am trying to learn asp.net MVC and having an issue to submit a
I'm trying to learn ASP.NET MVC + Entity Framework by developing a small project.
I am trying to learn some ASP.NET MVC. Please bear with me but asp.net
I have an Asp.Net background and trying to learn Silverlight. Can you explain, what

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.