必须选中复选框才能继续使用asp net [英] check boxes must be selected to continue asp net

查看:62
本文介绍了必须选中复选框才能继续使用asp net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在进行一项调查,并且有一个chechkbox列表,我需要并且防止这些chechkbox不会被取消。



在asp网络代码中我选择了< asp:customvalidator>



I am working on a survey and a have a chechkbox list, I need at the and to prevent that tthe chechkboxes are not left unchechked.

in the asp net code I have chosed as <asp:customvalidator>

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        For Each item As DataListItem In DataList1.Items
            If item.ItemType = ListItemType.Item Or item.ItemType = ListItemType.AlternatingItem Then
                Dim questionid As Integer
                Dim choiceid As Integer = 0
                Dim choicetext As String = ""
                questionid = CType(item.FindControl("Label3"), Label).Text
                Dim anstype As HiddenField = item.FindControl("HiddenField1")
                Select Case anstype.Value
                    Case "S"
                        Dim rbl As RadioButtonList = item.FindControl("RadioButtonList1")
                        If rbl.SelectedValue = "" Then
                            choiceid = 0
                        Else
                            choiceid = rbl.SelectedValue
                        End If
                        SaveAnswer(questionid, choiceid, "")
                    Case "M"
                        Dim cbl As CheckBoxList = item.FindControl("CheckBoxList1")
                        For i As Integer = 0 To cbl.Items.Count - 1
                            If cbl.Items(i).Selected Then
                                choiceid = cbl.Items(i).Value

                            Else
                                'MsgBox.show("Ve molime dopolnete gi site prasanja")
                            End If
                            SaveAnswer(questionid, choiceid, "")
                        Next
                    Case "T"
                        Dim txt As TextBox = item.FindControl("TextBox1")
                        choicetext = txt.Text
                        SaveAnswer(questionid, 0, choicetext)
                End Select
            End If
        Next
        DataList1.Visible = False
        Label5.Text = "Ви благодариме за учеството во анкетата!"
    End Sub

推荐答案

请参阅以下链接



如何使用Asp验证checkBox。净



使用自定义验证器验证复选框



使用CustomValidator进行asp.net单一CheckBox的客户端验证的JavaScript



如何验证ASP.Net中的CheckBox
Refer to below links

How to Validate checkBox using Asp.net

Using Custom Validator to Validate Checkbox

JavaScript for Clientside validation for asp.net Single-CheckBox using CustomValidator

How to Validate A CheckBox in ASP.Net


你的问题不清楚。简要说明您的问题。我会尝试提供解决方案。
YOur question isn''t clear. Give a brief description of your problem. I''ll try to provide a solution.


这篇关于必须选中复选框才能继续使用asp net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆