C# 使用twitter引导单选按钮替换html.radiobutton
我有几个单选按钮C# 使用twitter引导单选按钮替换html.radiobutton,c#,asp.net-mvc,twitter-bootstrap,C#,Asp.net Mvc,Twitter Bootstrap,我有几个单选按钮 <p>@Html.RadioButton("selected", "img")img @Html.RadioButton("selected", "input")input @Html.RadioButton("selected", "script")script @Html.RadioButton("selected", "link")link @Html.RadioButton("selected", "form")for
<p>@Html.RadioButton("selected", "img")img
@Html.RadioButton("selected", "input")input
@Html.RadioButton("selected", "script")script
@Html.RadioButton("selected", "link")link
@Html.RadioButton("selected", "form")form</p>
我有一种感觉,这不是正确的方法,因为助手可能与formcollection一起工作,它不知道引导css按钮是什么,但如果有一种方法来实现它,那就太好了
更新:
所以。。。这是我一直在寻找的解决方案 使用引导css的单选按钮
<div id="radios" class="btn-group view-opt-btn-group" data-toggle="buttons-radio">
<button type="button" class="btn" name="option-a" value="a">a</button>
<button type="button" class="btn" name="option-img" value="img">img</button>
<button type="button" class="btn" name="option-script" value="script">script</button>
<button type="button" class="btn" name="option-link" value="link">link</button>
<button type="button" class="btn" name="option-form" value="form">form</button>
<input type="hidden" name="option" value="0" />
</div>
<div id="radios" class="btn-group view-opt-btn-group" data-toggle="buttons-radio">
<button type="button" class="btn" name="option-a" value="a">a</button>
<button type="button" class="btn" name="option-img" value="img">img</button>
<button type="button" class="btn" name="option-script" value="script">script</button>
<button type="button" class="btn" name="option-link" value="link">link</button>
<button type="button" class="btn" name="option-form" value="form">form</button>
<input type="hidden" name="option" value="0" />
</div>
希望这会有所帮助。我还没有真正使用twitter引导程序(只是阅读了一下),而.NET不是我的强项,但是: 1)您需要使用input和type=“radio”来制作单选按钮,而不是按钮标签 2)twitter引导程序提供了应用于输入元素父元素的.radio和.inline类,如标签:
<label class="radio">
<input type="radio" name="selected" value="..." />
Text to come after the radio button
</label>
希望有帮助。所以。。。这是我一直在寻找的解决方案 使用引导css的单选按钮
<div id="radios" class="btn-group view-opt-btn-group" data-toggle="buttons-radio">
<button type="button" class="btn" name="option-a" value="a">a</button>
<button type="button" class="btn" name="option-img" value="img">img</button>
<button type="button" class="btn" name="option-script" value="script">script</button>
<button type="button" class="btn" name="option-link" value="link">link</button>
<button type="button" class="btn" name="option-form" value="form">form</button>
<input type="hidden" name="option" value="0" />
</div>
<div id="radios" class="btn-group view-opt-btn-group" data-toggle="buttons-radio">
<button type="button" class="btn" name="option-a" value="a">a</button>
<button type="button" class="btn" name="option-img" value="img">img</button>
<button type="button" class="btn" name="option-script" value="script">script</button>
<button type="button" class="btn" name="option-link" value="link">link</button>
<button type="button" class="btn" name="option-form" value="form">form</button>
<input type="hidden" name="option" value="0" />
</div>
希望这能有所帮助。非常好,这也回答了我的问题!感谢您的发帖和回复!:)很高兴你觉得它有用:)我们都在学习,坚强起来,我的儿子!
<label class="radio">
<input type="radio" name="selected" value="..." />
Text to come after the radio button
</label>
@Html.RadioButton("selected", "form", new { class = "class" });
<div id="radios" class="btn-group view-opt-btn-group" data-toggle="buttons-radio">
<button type="button" class="btn" name="option-a" value="a">a</button>
<button type="button" class="btn" name="option-img" value="img">img</button>
<button type="button" class="btn" name="option-script" value="script">script</button>
<button type="button" class="btn" name="option-link" value="link">link</button>
<button type="button" class="btn" name="option-form" value="form">form</button>
<input type="hidden" name="option" value="0" />
</div>
<script type="text/jscript">
$("body").find("#radios").children().each(function () {
$(this).bind('click', function () {
$("input[name=option]").val(this.value);
});
});
</script>
string selectedTechnology = form["option"];
whiteList.UrlType = selectedTechnology;