如何阻止ASP.NET更改ID以执行某些操作

时间:2013-07-31 06:51:52

标签: asp.net vb.net

我正在创建动态单选按钮列表

Dim rdbQuestion As New RadioButtonList

并且动态ID为

rdbQuestion.ID = "Question_" & row("Id").ToString

当页面呈现单选按钮列表的ID变为类似

AssessmentPerforma_Question_1, AssessmentPerforma_Question_2, AssessmentPerforma_Question_3..... AssessmentPerforma_Question_n

如何阻止asp.net更改ID以执行此类操作

Sub btnSave_click(ByVal sender As Object, ByVal e As EventArgs)

        Dim rbl As RadioButtonList = DirectCast(Page.FindControl("Question_1"), RadioButtonList)
        Response.Write(rbl.SelectedValue)
End Sub

1 个答案:

答案 0 :(得分:2)

添加此行....

rbdQuestion.ClientIDMode = ClientIDMode.Static