Vb6 “Tag” property equivalent in ASP.Net?

后端 未结 8 1268
迷失自我
迷失自我 2021-01-12 11:19

I\'m looking for ideas and opinions here, not a \"real answer\", I guess...

Back in the old VB6 days, there was this property called \"Tag\" in all controls, that wa

8条回答
  •  执笔经年
    2021-01-12 12:05

    The Tag property was always a weird wart-like thing that was useful as something off of which you could hang any data you wanted. But it wasn't strongly-typed and it didn't really make for a coherent design. The property itself just hung off the control like a weird knob. They kept it in WinForms to facilitate porting code over from VB6. The new WPF Control class doesn't have a Tag.

    With .NET you have full object-orientation and adequate type polymorphism, so you can strongly-type whatever extra information you want to associate with a code, whether it's in a subclass or a Dictionary.

    If it's in a single Page request and you want a general solution a Dictionary in the Page itself for each value type (e.g., Dictionary and Dictionary) should be exactly what you need.

提交回复
热议问题