Skip to main content
 首页 » 编程设计

c#之任何人都不应更改单选按钮选择

2024年02月20日11freeliver54

我在 C# 的 aspx 页面中制作了一个单选按钮列表

<asp:RadioButtonList ID="RblMentor_teacher_student" class="case"  runat="server" 
                        RepeatDirection="Horizontal" AppendDataBoundItems="False" > 
                        <asp:ListItem Text="Docent" Value="0"></asp:ListItem> 
                        <asp:ListItem Text="Mentor" Value="1"></asp:ListItem> 
                        <asp:ListItem Text="Student" Value="2"></asp:ListItem> 
                    </asp:RadioButtonList> 

如我所愿,它完美地显示了所选人员是教师、学生或导师。

但我希望没有人可以改变这个选择。

谁能帮忙。

请您参考如下方法:

您可以将它放在您的 Page_load() 中,它会禁用整个列表。

RblMentor_teacher_student.Enabled = false;   

或者您可以禁用特定的列表项

<asp:ListItem Text="Docent" Value="0" Disabled="Disabled"></asp:ListItem>