我有调用功能的单选按钮列表。停止单选按钮更改
如果该函数返回true,那么我想更改该值。
但是,如果该函数返回false,那么我不想更改该值并保留原始选择值。
目前它即使在语句返回false时也会更改该值。
有什么建议吗?
ASP页
<asp:RadioButtonList ID="rblType" runat="server" AutoPostBack="True"
DataSourceID="SqlData" DataTextField="Type"
DataValueField="TypeID">
</asp:RadioButtonList>
VB文件
Private selectionvalue As Integer
Protected Sub rblType_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles rblType.SelectedIndexChanged
Dim CheckListValidation As Boolean = CheckListBox()
If CheckListValidation = True Then
selectionvalue = rblType.SelectedItem.Value
Else
rblType.SelectedItem.Value = selectionvalue
End If
End Sub
Function CheckListBox() As Boolean
If lstbox.Items.Count <> "0" Then
If MsgBox("Are you sure you want to change option?", MsgBoxStyle.YesNo, " Change Type") = MsgBoxResult.Yes Then
Return True
Else
Return False
End If
Else
Return True
End If
End Function
你已经把一个断点?不确定CheckListBox()在做什么,但是这个事件是否会被多次调用,并且您的支票在后续的调用中返回true? CheckListBox()是否更改了值,而不是你粘贴的代码? –
好点 - 更新代码! – user3191666