2010-03-18 92 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 = 「一個」 啓用= 「假」>

相關問題