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 8843753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:18:39+00:00 2026-06-14T11:18:39+00:00

my application is MVC3 ASPX C#; I am trying to enable/disable Html.EditorFor using the

  • 0

my application is MVC3 ASPX C#; I am trying to enable/disable Html.EditorFor using the following:
In the Model:

 public bool IsReadOnly { get; private set; }

In the controller:

   if (MySession.Current._progress == 100)
       ViewData["ReadOnly"] = true;

In the view:

... Inherits="System.Web.Mvc.ViewPage<Models.CTAHFormEdit>" %>
 <script runat="server" type="text/C#">
        bool isReadOnly = false;
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((bool?)this.ViewData["ReadOnly"] == true)this.isReadOnly = true;
        }
    </script>
    <%: Html.EditorFor(model => model.Vessel_calcification, Model.IsReadOnly)%>

This did not work. I also tried:

  <%: Html.EditorFor(model => model.Subject_motion, new { @disable = true })%>

did not work also!

The best solution, becasue I also have dropdownlist and checkbox in the same view is to use @disable = true and @readonly = true or false and be able to change true of false using a ViewBag. Any suggestions, thanks in adavance.

  • 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-06-14T11:18:40+00:00Added an answer on June 14, 2026 at 11:18 am

    You can try this:

    @Html.TextBoxFor(model => model.Subject_motion, new { @readonly = "readonly" })
    

    Here’s an explanation of the difference between EditorFor and TextBoxFor:

    Differences between Html.TextboxFor and Html.EditorFor in MVC and Razor

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

Sidebar

Related Questions

I am developing an MVC3 application using Visual Studio 2010. I have an aspx
my application is MVC3 using ASPX views. I have two pages, create and Edit,
I'm trying to build a mvc3 application using VS 2010. But when every i
In my MVC3 Application I am using a controller actionresult to return two sets
I have a table in my .aspx view in MVC3 project. I am using
Trying to use security features and create Forms Authentication in my MVC3 application I
I am trying to setup Windows authentication in my .NET 4.0 MVC3 web application,
I'm trying to convert a small mvc2 application to the mvc3 razor syntax. In
my application is MVC3 (ASPX views). I have a form, in the Edit view
I am working on moving an application from MVC2 ASPX to MVC3 Razor, and

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.