我正在尝试进行验证,在点击ComboBox
中的某个项目而不检查任何RadioButton
后,它会向用户显示一条消息。这是我用来从项目中获取信息并将其填入DataGridView
的代码。
Private Sub cbExtensão_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cbExtensão.SelectedIndexChanged
If cbExtensão.Visible <> cbExtensão.V(rbPorData.Checked & rbPorExtensão.Checked & rbPorNome.Checked) Then
If rbPorData.Checked Then
DataGridView2.DataSource = FillDataGridViewData(cbExtensão.Text)
ElseIf rbPorExtensão.Checked Then
DataGridView2.DataSource = FillDataGridViewExtensao(cbExtensão.Text)
ElseIf rbPorNome.Checked Then
DataGridView2.DataSource = FillDataGridViewName(cbExtensão.Text)
End If
Else
MsgBox("Please, check an option to search")
End If
End Sub
我要做的是用这条线If cbExtensão.Visible <> cbExtensão.V(rbPorData.Checked & rbPorExtensão.Checked & rbPorNome.Checked) Then
制作一些东西,但我已经尝试了很多东西而且我从那里得不到任何东西。基本上我希望它在用户点击RadioButton
CheckBox
时显示消息
答案 0 :(得分:0)
这就是我为我的代码所做的工作。
Private Sub UserMsgBox(ByVal sMsg As String)
Dim sb As New StringBuilder()
Dim oFormObject As System.Web.UI.Control
sMsg = sMsg.Replace("'", "\'")
sMsg = sMsg.Replace(Chr(34), "\" & Chr(34))
sMsg = sMsg.Replace(vbCrLf, "\n")
sMsg += "<script language=javascript "
sMsg += "type=text/" + "javascript" + ">"
smsg += "alert ('" + "Please click on a code type" + "')"
sMsg += "</" + "script" + ">"
sb = New StringBuilder()
sb.Append(sMsg)
Page.RegisterclientScriptBlock("clientScript", sMsg)
For Each oFormObject In Me.Controls
If TypeOf oFormObject Is HtmlForm Then
Exit For
End If
Next
' Add the javascript after the form object so that the
' message doesn't appear on a blank screen.
oFormObject.Controls.AddAt(oFormObject.Controls.Count, New LiteralControl(sb.ToString()))
end sub
答案 1 :(得分:0)
正如Plutonix在评论中提到的,你可以删除第一个document
声明......
First Name
<input type="text" name="fname" id="fname" value="" />
Email
<input type="text" name="email" id="email" value="" />
Password</td>
<input type="password" name="pass" id="pass" value="" />
Re Password
<input type="password" name="rpass" id="rpass" value="" />
因此,如果未选择任何框,则会降至if
语句。