菜单 学习猿地 - LMONKEY

VIP

开通学习猿地VIP

尊享10项VIP特权 持续新增

知识通关挑战

打卡带练!告别无效练习

接私单赚外块

VIP优先接,累计金额超百万

学习猿地私房课免费学

大厂实战课仅对VIP开放

你的一对一导师

每月可免费咨询大牛30次

领取更多软件工程师实用特权

入驻
358
0

javascript判断是否有对RadioButtonList选项选择

原创
05/13 14:22
阅读数 6341




复制代码 代码如下:

Imports Microsoft.VisualBasic
Namespace Insus.NET
Public Class Cosmetic
Private _ID As Integer
Private _Type As String
Private _Name As String
Private _Weight As Decimal
Private _UM As String
Public Property ID As Integer
Get
Return _ID
End Get
Set(value As Integer)
_ID = value
End Set
End Property
Public Property Type As String
Get
Return _Type
End Get
Set(value As String)
_Type = value
End Set
End Property
Public Property Name As String
Get
Return _Name
End Get
Set(value As String)
_Name = value
End Set
End Property
Public Property Weight As Decimal
Get
Return _Weight
End Get
Set(value As Decimal)
_Weight = value
End Set
End Property
Public Property UM As String
Get
Return _UM
End Get
Set(value As String)
_UM = value
End Set
End Property
Public Sub New()
End Sub
Public Sub New(id As Integer, type As String, name As String, weight As Decimal, um As String) LdePlr
Me._ID = id
Me._Type = type
Me._Name = name
Me._Weight = weight
Me._UM = um
End Sub
Public Function GetData() As List(Of Cosmetic)
Dim o As New List(Of Cosmetic)
Dim c As New Cosmetic(1, "滋润霜", "玉兰油", 50, "g")
o.Add(c)
Dim c1 As New Cosmetic(2, "滋润霜", "雅诗兰黛", 100, "g")
o.Add(c1)
Dim c2 As New Cosmetic(3, "滋润霜", " 兰蔻", 80, "g")
o.Addhttp://www.cppcns.com(c2)
Dim c3 As New Cosmetic(4, "滋润霜", "欧莱雅", 60, "g")
o.Add(c3)
Dim c4 As New Cosmetic(5, "滋润霜", "芭比波朗", 120, "g")
o.Add(c4)
Return o
End Function
End Class

End Namespace


复制代码 代码如下:

化妆品:<asp:RadioButtonList ID="RadioButtonListCosmLdePlretic" runat="server" RepeatColumns="10" RepeatDirection="Horizontal"></asp:RadioButtonList>
<br />
<asp:Button ID="Button1" runat="server" Text="Select" />

编程客栈
复制代码 代码如下:

Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not IsPostBack Then
Data_Binding()
End If
End Sub
Private Sub Data_Binding()
Dim objCosmetic As New Cosmetic()
Me.RadioButtonListCosmetic.DataSource = objCosmetic.GetData()
Me.RadioButtonListCosmetic.DataTextField = "Name"
Me.RadioButtonListCosmetic.DataValueField = "ID"
Me.RadioButtonListCosmetic.DataBind()
End Sub

java
复制代码 代码如下:

View Code
<script type="text/javascript">
function CheckIsSelected() {
var rbl = document.getEleLdePlrmentById("<%=RadioButtonListCosmetic.ClientID%>");
var radio = rbl.getElementsByTagName("input");
var isSelect = false;
for (var i = 0; i < radio.length; i++) {
if (radio[i].checked) {
isSelect = true;
break;
}
}
if (!isSelect) {
alert("请选择一个选项。");
}
return isSelect;
}
</script>


复制代码 代码如下:

<asp:Button ID="Button1" runat="server" Text="Select" OnClientClick="return CheckIsSelected()" />
本文标题: javascript判断是否有对RadioButtonList选项选择
本文地址: http://www.cppcns.com/wangluo/aspnet/91289.html

发表评论

0/200
358 点赞
0 评论
收藏
为你推荐 换一批