locked
Suppress Conditional Attribute Warnings RRS feed

  • Question

  • User938738290 posted

    I'm working on a Razor v2 Web Pages site in VS 2013 Express for Web, and a lot of my pages include markup like the following:

    <input type="text" name="SomeField" disabled="@SomeDAO.DisableSomeField()" />
    <select name="SomeSelect">
        <option value="0" selected="@(SomeDAO.SomeSelectValue == 0)">Zero</option>
        <option value="1" selected="@(SomeDAO.SomeSelectValue == 1)">One</option>
    </select>

    Problem is, all of those conditions on the disabled and selected attributes aren't recognized as valid by the compiler, so I've got a pretty massive stack of warnings of the form "'@SomeDAO.DisableSomeField()' is not a valid value of attribute 'disable'".

    While it's not causing any problems in the actual execution of the program (The boolean expressions evaluate just fine at runtime and enable/disable/select the right things), it would be nice to suppress these warnings so that I could focus on any others that could actually be problematic.  Anyone have thoughts on how to do that?

    Friday, April 11, 2014 9:17 AM

Answers

  • User938738290 posted

    Starain chen - MSFT

    What’s your project type? (E.g. MVC)

    emu42

    I'm working on a Razor v2 Web Pages site

    Looks like I can't actually reproduce it either after booting up my computer this morning.  IntelliSense might have just needed some time or a reboot to get itself together?

    Thanks anyway.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 14, 2014 9:17 AM

All replies

  • User-1454326058 posted

    Hi emu42,

    What’s your project type? (E.g. MVC)

    Based on my test in the web application project (Add a razor page) and MVC project, I can’t reproduce your scene.

    Please reset the VS settings (Tools=>Settings=>Reset), then create a new project and try again.

    If you can still reproduce that scene, please share the project to me.

    About share the files in the OneDrive, please refer to:

    # Share files and folders and change permissions

    http://windows.microsoft.com/en-us/onedrive/share-file-folder

    Thanks

    Best Regards

    Monday, April 14, 2014 12:41 AM
  • User938738290 posted

    Starain chen - MSFT

    What’s your project type? (E.g. MVC)

    emu42

    I'm working on a Razor v2 Web Pages site

    Looks like I can't actually reproduce it either after booting up my computer this morning.  IntelliSense might have just needed some time or a reboot to get itself together?

    Thanks anyway.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 14, 2014 9:17 AM
  • User-1454326058 posted

    Hi emu42,

    Maybe something updates installed or errors occur which affect it works fine. So reboot the computer, it will fixed them.

    On the other hand, you could try to clear the whole solution if you find the issue again.

    Thanks

    Best Regards

    Monday, April 14, 2014 11:10 PM