Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# HTML输入类型单选按钮在页面加载时不显示所选内容_C#_Html_Asp.net_Webforms - Fatal编程技术网

C# HTML输入类型单选按钮在页面加载时不显示所选内容

C# HTML输入类型单选按钮在页面加载时不显示所选内容,c#,html,asp.net,webforms,C#,Html,Asp.net,Webforms,我一直在尝试获取适当的输入类型单选按钮,以便根据页面加载时数据库中的值进行选择。它应显示所选的相应按钮,例如,如果文件类型为“分隔”,则应选择分隔按钮。我已经验证了背后的代码,它工作正常。我还检查了显示checked=“checked”的页面源代码,但按钮仍然没有显示为选中状态。我用一个普通的asp.RadioButton试用过,效果很好,为什么在这里不起作用? 代码隐藏在OnInit方法中运行 HTML 由于data toggle=“buttons”复选框不起作用,因此您必须将活动类添加到活动

我一直在尝试获取适当的输入类型单选按钮,以便根据页面加载时数据库中的值进行选择。它应显示所选的相应按钮,例如,如果文件类型为“分隔”,则应选择分隔按钮。我已经验证了背后的代码,它工作正常。我还检查了显示checked=“checked”的页面源代码,但按钮仍然没有显示为选中状态。我用一个普通的asp.RadioButton试用过,效果很好,为什么在这里不起作用? 代码隐藏在OnInit方法中运行

HTML
由于
data toggle=“buttons”
复选框不起作用,因此您必须将活动类添加到活动按钮中

<asp:label class="form__label" id="switchLabel_FileType" runat="server">File Type</asp:label>
<div id="FileType" class="btn-group" data-toggle="buttons" style="width:100%">
            <asp:label class="btn btn-primary btn-small" id="Label1"  runat="server">
                <input type="radio" name="options"    style="width:33%" /> Delimited
            </asp:label>


            <asp:label class="btn btn-primary btn-small" id="Label2"  runat="server">
            <input type="radio" name="options"   style="width:33%"/> Excel
            </asp:label>


            <asp:label class="btn btn-primary btn-small" id="Label3"  runat="server">
            <input type="radio" name="options"  style="width:33%"/> Fixed Width
            </asp:label> </div> 

你介意发布一个呈现HTML的相关示例吗?可以吗?你在不同的浏览器中尝试过吗?是的,我在IE和Chrome中都尝试过。这是它在页面源代码中显示的内容。删除data toggle=“button”会将其转换为常规单选按钮。我不希望这样做,因为这些按钮与这些圆圈不匹配。
            string fType = row[Constants.FILE_TYPE].ToString();
            if (fType == Constants.FILETYPE_DELIMITED)
            {
                label_Delimited.Checked = true;
            }

            else if (fType == Constants.FILETYPE_XLS)
            {
                label_Excel.Checked = true;
            }

            else if (fType == Constants.FILETYPE_FIXEDWIDTH)
            {
                label_FixedWidth.Checked = true;
            }
<asp:label class="form__label" id="switchLabel_FileType" runat="server">File Type</asp:label>
<div id="FileType" class="btn-group" data-toggle="buttons" style="width:100%">
            <asp:label class="btn btn-primary btn-small" id="Label1"  runat="server">
                <input type="radio" name="options"    style="width:33%" /> Delimited
            </asp:label>


            <asp:label class="btn btn-primary btn-small" id="Label2"  runat="server">
            <input type="radio" name="options"   style="width:33%"/> Excel
            </asp:label>


            <asp:label class="btn btn-primary btn-small" id="Label3"  runat="server">
            <input type="radio" name="options"  style="width:33%"/> Fixed Width
            </asp:label> </div> 
        Label1.Attributes.Add("Class", "btn btn-primary btn-small active");
        Label2.Attributes.Add("Class", "btn btn-primary btn-small");
        Label3.Attributes.Add("Class", "btn btn-primary btn-small");