如何将重点放在2复选框列表上

时间:2019-05-15 02:01:59

标签: javascript asp.net asp.net-mvc

我有2个复选框-ID为program_0和program_1。当我选择第二个复选框时,焦点将跳到第一个复选框。如何在选中框的位置设置焦点?我尝试了这个脚本

" ScriptManager.RegisterStartupScript(Me, Me.GetType, "rblAvailableTriggerFocus",
                                                String.Format("$('#{0}_{1}').focus();", rblAvailable.ClientID, rblAvailable.SelectedIndex)

,                                                 True)”,但它不起作用。此功能有效受保护的子rblAvailable_SelectedIndexChanged,但程序功能无效。

 ScriptManager.RegisterStartupScript(Me, Me.GetType, "chkProgramsTriggerFocus",
                                            String.Format("$('#{0}_{1}').focus();", chkPrograms.ClientID, chkPrograms.SelectedIndex),
                                            True)

Protected Sub chkPrograms_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)

    Dim chk As CheckBoxList = sender
    Dim ucVerificationSummaryAll As UserControlVerificationSummaryAll = phVerificationSummary.FindControl("ucVerificationSummaryAll")

    For Each item As ListItem In chk.Items
        With ucVerificationSummaryAll
            .ToggleShowHideProgram(item.Value, item.Selected)

        End With
    Next

    ScriptManager.RegisterStartupScript(Me, Me.GetType, "chkProgramsTriggerFocus",
                                            String.Format("$('#{0}_{1}').focus();", chkPrograms.ClientID, chkPrograms.SelectedIndex),
                                            True)
End Sub

Protected Sub rblAvailable_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rblAvailable.SelectedIndexChanged

    If _intProgramID > 0 And _intAppID > 0 Then
        Dim ucVerificationSummary As UserControlVerificationSummary = phVerificationSummary.FindControl("ucVerificationSummary")
        With ucVerificationSummary
            .ToggleVerifications(Me.rblAvailable.SelectedValue)

        End With
    Else
        Dim ucVerificationSummaryAll As UserControlVerificationSummaryAll = phVerificationSummary.FindControl("ucVerificationSummaryAll")
        With ucVerificationSummaryAll
            .ToggleVerifications(Me.rblAvailable.SelectedValue)

        End With
    End If
    ScriptManager.RegisterStartupScript(Me, Me.GetType, "rblAvailableTriggerFocus",
                                            String.Format("$('#{0}_{1}').focus();", rblAvailable.ClientID, rblAvailable.SelectedIndex),
                                            True)
End Sub

选中第二个复选框后,焦点将跳转到第一个复选框。

0 个答案:

没有答案