2010-03-18 94 views
5

我正在使用一个asp单选按钮组在表单中列出答案。这里是一个结构的例子(我知道这些文字没有意义,只和我一起)。有没有办法禁用标签?

<asp:RadioButtonList id="Q2" runat="server"> 
    <asp:ListItem Text="Go to <a target='_blank' href='http:www.google.com'>Google</a>" Value="a"></asp:ListItem> 
    <asp:ListItem Text="Go to <a target='_blank' href='http:www.yahoo.com'>Yahoo</a>" Value="a"></asp:ListItem> 
</asp:RadioButtonList> 

所以,我想能够点击链接,并没有与它关联的单选按钮被选中。在IE浏览器中工作正常,但在Firefox中单击按钮时将单击链接。我真的不需要标签来真正选择适当的单选按钮,所以有没有办法只是禁用它们在javascript或asp或C#代码中的某个地方?

+2

由此产生的HTML看起来像什么?浏览器从来没有看到ASP代码 – Pickle 2010-03-18 19:06:09

回答

3

它无疑是一个label元件,它是给你的选择行为中包装它们。您可以手动生成代码 - 我的选择 - 或者在客户端用javascript解开它们。

<div> 
    <input type="radio" name="Q2" id="Q2_google" value="google" /> <a target="_blank" href="http://www.google.com">Google</a> 
    ... 
</div> 

或客户端

$(function() { 
    $('label:has(a)').each(function() { 
     var html = $(this).html(); 
     $(this).replaceWith($(html)); 
    }); 
}); 
+0

是啊jquery看起来像我注意到的大多数编码问题的方式。 – Mike 2010-04-02 18:14:36

0

试试这个:

<a target='_blank' href='http:www.google.com' click='return false;'>Google</a>" 
0

您仍可使用可在列表项级别

防爆= “假”: 谷歌” VALUE = “一个” 启用= “假”>

相关问题