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 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

Ask A Question

Stats

  • Questions 69k
  • Answers 69k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer An interesting potential option would be to use a variant… May 11, 2026 at 12:37 pm
  • added an answer You may have heard of PediaPress, a company that has… May 11, 2026 at 12:37 pm
  • added an answer Bugzilla, while an issue tracker rather than a requirements gathering… May 11, 2026 at 12:37 pm

Related Questions

I am trying to decide whether to learn ASP.NET MVC (or to spend the
I am a ASP.NET Developer trying to learn Rails and RESTful approach. To understand,
I am trying to learn the keyboard shortcuts in Visual Studio in order to
I am trying to learn some of the basic and advanced features of visual
I have experience in PHP, JSP/servelts and classic ASP, and I am trying to
I am trying to figure out how to use ASP.NET MVC and it seems
I am working on an ASP.NET MVC web application, and am working on the

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.