【问题标题】:HTML Radio buttons runat=server not workingHTML 单选按钮 runat=server 不工作
【发布时间】:2013-06-24 01:29:11
【问题描述】:

我有以下标记:

<div class="control-group">
    <label class="control-label" for="rdbActive">Active</label>
    <div class="controls">
        <label class="radio inline" for="rdbActive0">
        <input name="rdbActive" id="rdbActive0" value="Yes" checked="checked" type="radio">Yes
        </label>
        <label class="radio inline" for="rdbActive1">
        <input name="rdbActive" id="rdbActive1" value="No" type="radio">No
        </label>
    </div>
</div>

如何制作这个 runat=server?

对于文本输入,我所做的只是:

<div class="control-group">
    <label class="control-label" for="txtDescription">Description</label>
    <div class="controls">
        <input id="txtDescription" runat="server" name="txtDescription" placeholder="" class="input-large" type="text">
    </div>
</div>

..我可以从后面的代码中访问它。如果我将它添加到任何单选按钮,我会收到 500 服务器错误。

【问题讨论】:

    标签: html asp.net twitter-bootstrap


    【解决方案1】:

    您可以使用runat="server" 创建单选按钮:

    <asp:RadioButton id="RadioButton1" AutoPostBack="True|False" Checked="True|False" GroupName="GroupName" Text="label" TextAlign="Right|Left" OnCheckedChanged="OnCheckedChangedMethod" runat="server" />
    

    其中OnCheckedChangedMethod 是在选中单选按钮时调用的代码隐藏方法。

    在 MSDN 网站上查看 reference

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-04-07
      • 1970-01-01
      • 1970-01-01
      • 2016-05-04
      • 2017-02-05
      • 2011-05-03
      • 2011-03-27
      相关资源
      最近更新 更多