Why does VS remove my inline code when editing completely unrelated controls in an ASPX page?


  • Good afternoon all!

    I've run into a rather annoying issue and was hoping someone could say "oh that's happening because x, y and z!"

    I am using VS 2013 Professional version 12.0.40629.00 Update 5 to develop a website. On one of the pages the following code exists:

        <% if (Profile.PasswordRecoveryEnabled == false)
           <%-- DO WORK HERE --%>
        <%       } %>

    The above lines appear right below the page declaration, line 5 to be exact.

    I inserted a Literal control on the design surface, and went to rename it. Once I click out of the name box on the property sheet, suddenly my code changes and my inline code above (with the exception of what is in the <%-- DO WORK HERE --%> spot) is changed to:

        <%-- Label and controls go here. --%>
        <%-- DO WORK HERE --%>
        <%-- Label and controls go here. --%>

    This obviously isn't okay. Is there a reason why this is happening?

    I have no clue why something like this would happen, but it makes it very difficult to work on a page when it keeps changing my markup for, what I consider, no apparent reason.

    Any thoughts?

    Friday, July 22, 2016 6:52 PM


  • Hi Zach Attack,

    One possible reason is that we couldn't add custom code in certain tag/property or others.

    Like this blog here:

    Look at this :

    <%      %>

    these tags what we talk about. It comes from ASP classic style and it used in PHP and JSP too for the same reason "Writing Server Side Code ".

    Note: you must know that we can't use it in code behind (Page.aspx.cs ) .

    Not the real Web developer, since this issue is related to the website project, to really repro and resolve this issue, I suggest you could post this issue in where experts live in, and there you would get dedicated support. At least, we could know that whether it is related to the VS IDE or the specific project code or by design.

    Best Regards,

    Jack Zhai

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, July 25, 2016 7:04 AM