N
Nathan Sokalski
I am using the AddHandler statement to add a CheckedChanged event handler to
a series of RadioButtons that I create in a loop. However, the handler is
not being called for a reason I cannot determine. What is the problem? Here
is my code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
currpoem = Server.UrlDecode(Request.QueryString("poem"))
Dim ratinglabels As New TableRow
Dim ratingselection As New TableRow
For i As Integer = 1 To 10
Dim currlabel As New TableCell
currlabel.EnableViewState = False
currlabel.Font.Names = New String() {"Arial", "Helvetica",
"Sans-Serif"}
currlabel.Font.Size = FontUnit.Medium
currlabel.HorizontalAlign = HorizontalAlign.Center
currlabel.Text = i
ratinglabels.Cells.Add(currlabel)
Dim currselection As New TableCell
Dim radioselection As New RadioButton
currselection.EnableViewState = False
currselection.HorizontalAlign = HorizontalAlign.Center
radioselection.GroupName = "poemscore"
radioselection.ID = "radScore" & i
AddHandler radioselection.CheckedChanged, AddressOf
Me.Rating_CheckedChanged
currselection.Controls.Add(radioselection)
ratingselection.Cells.Add(currselection)
Next
tblRatingChoices.Rows.Add(ratinglabels)
tblRatingChoices.Rows.Add(ratingselection)
lblRatePoem.Text = "Rate Poem:<br>" & currpoem
TitleBar.InnerText = "Rate Poem: " & currpoem
btnClose.Attributes.Add("onClick=", "window.close();")
End Sub
Private Sub Rating_CheckedChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs)
score = CByte(CType(sender, RadioButton).ID.Substring(8))
btnSubmit.Enabled = True
End Sub
When the page is run, everything looks as expected, but the CheckedChanged
event does not fire (or at least it does not call the Rating_CheckedChanged
procedure as expected). Any ideas? Thanks.
a series of RadioButtons that I create in a loop. However, the handler is
not being called for a reason I cannot determine. What is the problem? Here
is my code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
currpoem = Server.UrlDecode(Request.QueryString("poem"))
Dim ratinglabels As New TableRow
Dim ratingselection As New TableRow
For i As Integer = 1 To 10
Dim currlabel As New TableCell
currlabel.EnableViewState = False
currlabel.Font.Names = New String() {"Arial", "Helvetica",
"Sans-Serif"}
currlabel.Font.Size = FontUnit.Medium
currlabel.HorizontalAlign = HorizontalAlign.Center
currlabel.Text = i
ratinglabels.Cells.Add(currlabel)
Dim currselection As New TableCell
Dim radioselection As New RadioButton
currselection.EnableViewState = False
currselection.HorizontalAlign = HorizontalAlign.Center
radioselection.GroupName = "poemscore"
radioselection.ID = "radScore" & i
AddHandler radioselection.CheckedChanged, AddressOf
Me.Rating_CheckedChanged
currselection.Controls.Add(radioselection)
ratingselection.Cells.Add(currselection)
Next
tblRatingChoices.Rows.Add(ratinglabels)
tblRatingChoices.Rows.Add(ratingselection)
lblRatePoem.Text = "Rate Poem:<br>" & currpoem
TitleBar.InnerText = "Rate Poem: " & currpoem
btnClose.Attributes.Add("onClick=", "window.close();")
End Sub
Private Sub Rating_CheckedChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs)
score = CByte(CType(sender, RadioButton).ID.Substring(8))
btnSubmit.Enabled = True
End Sub
When the page is run, everything looks as expected, but the CheckedChanged
event does not fire (or at least it does not call the Rating_CheckedChanged
procedure as expected). Any ideas? Thanks.