【问题标题】:HtmlInputRadioButton Checked property not working in ChromeHtmlInputRadioButton Checked 属性在 Chrome 中不起作用
【发布时间】:2014-07-08 12:52:11
【问题描述】:

radio 类型的 html 输入是使用 jQuery 的 .prop() 函数设置的。然后使用 .Checked 属性在 aspx.cs(C#) 中检查它是否被选中。

html:

<input id="AmountRadio" enableviewstate="true" runat="server" type="radio" value="Amount" onclick="ChangeVisibility('a')" />

在 ChangeVisibility 函数中设置属性:

var amountRadio = $('#AmountRadio'); amountRadio.prop('checked', true);

在 C# 中:

if(AmountRadio.Checked)

当应用程序在 IE 中运行时,C# 中的 Checked 属性可以正常工作。但是当在 Chrome 中运行时,Checked 属性总是返回 false。 有人对这个有想法吗?

【问题讨论】:

  • 什么是amountRadio
  • 是输入ctrl的ID。已编辑的问题。
  • 试试这个 amountRadio.attr('checked', true); 或 amountRadio.attr('checked', 'checked');
  • 抱歉没用。我也试过 amountRadio.prop('checked', 'checked');amountRadio.prop({checked: true}); 。一旦 jQuery LoC 被执行,单选按钮的选中属性就会被视为 true。但是在 IE 和 Chrome 中运行时,代码背后的差异仍然存在。

标签: c# jquery google-chrome


【解决方案1】:

最终使用隐藏字段来存储单选按钮的值以使功能正常工作。不过想知道真正的解决方案。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-01
    • 2020-10-08
    • 1970-01-01
    • 2019-01-15
    • 2015-02-25
    • 2019-03-14
    相关资源
    最近更新 更多