How can assign a data-group value to an html element created in C#?

前端 未结 1 1845
-上瘾入骨i
-上瘾入骨i 2021-01-25 16:39

I have a scenario where I need to conditionally slide up (or hide) sets of controls/elements. I like the answer I found here from QBM5 about assigning data-groups to the control

相关标签:
1条回答
  • 2021-01-25 17:05

    First off, please notice that DataGroup or data-group is nothing predefined, it's an HTML5 data-* attribute which can be named anything you like.

    Since you are working with ASP.NET and WebForms, you can use the Attributes collection on your TextBox element like this:

    boxRequesterName.Attributes.Add("data-group", "1");
    

    See on MSDN WebControl.Attributes and AttributeCollection.

    0 讨论(0)
提交回复
热议问题