Can I stop .NET eating IDs?

前端 未结 10 1487
我寻月下人不归
我寻月下人不归 2020-12-16 11:35

I\'m an Information Architect and JavaScript developer by trade nowadays, but recently I\'ve been getting back into back-end coding again. And, whilst trying to get an HTML

10条回答
  •  既然无缘
    2020-12-16 12:11

    You definitely don't want to hard-code the asp.net-generated ID into your CSS, because it can change if you rearrange things on your page in such a way that your control tree changes.

    You're right that CSS IDs have their place, so I would ignore the suggestions to just use classes.

    The various javascript hacks described here are overkill for a small problem. So is inheriting from a class and overriding the ID property. And it's certainly not helpful to suggest switching to MVC when all you want to do is refactor some CSS.

    Just have separate divs and spans that you target with CSS. Don't target the ASP.NET controls directly if you want to use IDs.

      
    ......

提交回复
热议问题