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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:11:07+00:00 2026-06-05T16:11:07+00:00

I am doing some server stuff that could potentially fail (not likely) but something

  • 0

I am doing some server stuff that could potentially fail (not likely) but something can go wrong. I want to stop the user from going any further so I want to disable the input so that they have to refresh the page. How can I disable it based on ModelState errors. If any errors exist, disable this box and I only want to do it when the page is initially loaded. My problem is not necessarily how to do it but more what is the standard and the best way to do it. I could have a ViewBag that holds a true false for disabling it but not sure if that’s the best route, any suggestions?

  • 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-05T16:11:09+00:00Added an answer on June 5, 2026 at 4:11 pm

    Let’s suppose that you have a POST controller action that does some processing and adds errors to the ModelState if it fails which pretty standard. Now inside the view you could:

    @Html.TextBoxFor(
        x => x.SomeProperty, 
        !ViewData.ModelState.IsValid ? new { @readonly = "readonly" } : null
    )
    

    or write a custom helper that will do the job and simplify things up for you:

    @Html.MyTextBoxFor(x => x.SomeProperty)
    

    Could be useful if you need this behavior for multiple input fields.

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

Sidebar

Related Questions

Does SQL Server 2005 maintain built-in, queryable, row-level last-modified timestamp metadata? I'm doing some
I'm building a WPF application. I'm doing some async communication with the server side,
While doing some refactoring I've found that I'm quite often using a pair or
I'm doing some work for a charity that's having a fund drive. Whenever someone
I have some experience with JavaScript - but mainly with some small stuff, I
I am making a PHP script that does some stuff for me, so I
I am a web guy doing mostly Perl server-side stuff, and I'm slowly coming
Doing some jquery animation. I have certain divs set up with an attribute of
Doing some homework here (second assignment, still extremely green...). The object is to read
While doing some JavaScript performance tests I came up with the following piece of

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.