adward
adward

Reputation: 289

How to stop ASP.NET from changing IDs in order to perform some operation

i am creating dynamic radio button lists

Dim rdbQuestion As New RadioButtonList

and there dynamic Ids as

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

And when the page rendered the id of Radio Button Lists changes to something like this

AssessmentPerforma_Question_1, AssessmentPerforma_Question_2, AssessmentPerforma_Question_3..... AssessmentPerforma_Question_n

How can I stop asp.net from changing IDs in order to perform a operation like this

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

Upvotes: 0

Views: 84

Answers (1)

Abdul Basit
Abdul Basit

Reputation: 722

add this line....

rbdQuestion.ClientIDMode = ClientIDMode.Static

Upvotes: 2

Related Questions