单选按钮焦点问题 [英] Radio Button focus Issue

查看:95
本文介绍了单选按钮焦点问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在单选按钮列表检查更改事件中写了以下代码

I have written below code in radio button list check change event

protected void rblStatus_SelectedIndexChanged(object sender, EventArgs e)
    {
        //To get focus on radio button which is selected
        var script = string.Format("document.getElementById('{0}_{1}').focus();", rblStatus.ClientID, rblStatus.SelectedIndex);

        if (ScriptManager.GetCurrent(this) != null && ScriptManager.GetCurrent(this).IsInAsyncPostBack)
        {
            ScriptManager.RegisterStartupScript(rblStatus, typeof(RadioButtonList), Guid.NewGuid().ToString(), script, true);
        }
        else
        {
            ClientScript.RegisterStartupScript(typeof(RadioButtonList), Guid.NewGuid().ToString(), script, true);
        }

        //	Open - 1
        //  Close - 2
        //	Extension - 3
        //  Completion - 4	
        //	Inprogress - 5
        
        List<CorrectiveActionExtension> correctiveActionStatus = new List<CorrectiveActionExtension>();
        correctiveActionStatus = (List<CorrectiveActionExtension>)ViewState["dataSource"];

        int i = 0;
        foreach (CorrectiveActionExtension CAItem in correctiveActionStatus)
        {

            if (i == int.Parse(ViewState["index"].ToString()))
            {
                txtDescription.Text = CAItem.Remarks.ToString();

                if (rblStatus.SelectedValue.Equals("3"))
                {
                    divTargetDate.Visible = true;
                    ulTargetDate.DateTime = (CAItem.TargetDate == null ? DateTime.Now : CAItem.TargetDate);
                }
                else
                {
                    divTargetDate.Visible = false;
                    ulTargetDate.DateTime = null;
                   // txtDescription.T
                }

            }
            i++;
        }
        mdlChangeStatus.Show();
    }





用于关注单选按钮列表的代码是



In which code used to get focus on radio buttonlist is

var script = string.Format("document.getElementById('{0}_{1}').focus();", rblStatus.ClientID, rblStatus.SelectedIndex);

        if (ScriptManager.GetCurrent(this) != null && ScriptManager.GetCurrent(this).IsInAsyncPostBack)
        {
            ScriptManager.RegisterStartupScript(rblStatus, typeof(RadioButtonList), Guid.NewGuid().ToString(), script, true);
        }
        else
        {
            ClientScript.RegisterStartupScript(typeof(RadioButtonList), Guid.NewGuid().ToString(), script, true);
        }



现在我的问题是在加载时我没有从单选按钮列表中选择单选按钮。

请帮忙我要解决这个问题。


Now my issue is while loading this i dont get focus on selected radio button from radio button list.
Please help me to solve this.

推荐答案

你应该把重点放在rblStatus而不是单个选定的列表项上。需要做这样的事情:





You should set focus on rblStatus and not on individual selected list item. Need to do something like this:


document.getElementById(''<%= rblStatus.ClientID %>'').focus();


这篇关于单选按钮焦点问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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