Accessing HTML Elements in ASP.Net

后端 未结 3 923
情话喂你
情话喂你 2021-01-12 09:08

I want to change the text of a radio button (html element) not ASP.NET component.

How can I change it from ASP.NET?

Thanks

3条回答
  •  攒了一身酷
    2021-01-12 09:11

    A simple RadioButtonList, when initialized like this:

    list.Items.Add(new ListItem("item 1", "1"));
    list.Items.Add(new ListItem("item 2", "2"));
    list.Items.Add(new ListItem("item 3", "3"));
    

    renders to the following HTML:

    So via JavaScript you can loop through the elements with the type "radio", grab their id and then look for label elements that have the id as the 'for' value. And update their innerHTML.

提交回复
热议问题