我正在尝试为RadioButtonList的每个ListItem的任何 <input>、<td> 或 <label> 元素添加一些onmouseover和onmouseout属性。我该怎么做呢?这是我尝试过的。这不起作用...
ASPX 文件...
<asp:RadioButtonList ID="RadioButtonListPaymentFrequency"
runat="server"
RepeatDirection="Vertical"
RepeatLayout="Table"
RepeatColumns="1" />
VB代码背后...
将 ListItemOneTimeOnly 调暗为新的 ListItem("One-Time Only", "1") ListItemOneTimeOnly.Attributes.Add("onmouseover", "ddrivetip('示例:一次性支付 300 美元的总金额意味着 1 次支付 300 美元。')") ListItemOneTimeOnly.Attributes.Add("onmouseout", "hideddrivetip()") RadioButtonListPaymentFrequency.Items.Add(ListItemOneTimeOnly) 将 ListItemMonthly 调暗为新 ListItem("Monthly", "12") ListItemMonthly.Attributes.Add("onmouseover", "ddrivetip('示例:每月支付 300 美元的总金额意味着 12 次支付 25 美元。')") ListItemMonthly.Attributes.Add("onmouseout", "hideddrivetip()") RadioButtonListPaymentFrequency.Items.Add(ListItemMonthly) 将 ListItemQuarterly 调暗为新 ListItem("Quarterly", "4") ListItemQuarterly.Attributes.Add("onmouseover", "ddrivetip('示例:每季度支付 300 美元的总金额意味着 4 次支付 75 美元。')") ListItemQuarterly.Attributes.Add("onmouseout", "hideddrivetip()") RadioButtonListPaymentFrequency.Items.Add(ListItemQuarterly) Dim ListItemSemiannually As New ListItem("Semiannually", "2") ListItemSemiannually.Attributes.Add("onmouseover", "ddrivetip('示例:每月支付 300 美元的总金额意味着 2 次支付 150 美元。')") ListItemSemiannually.Attributes.Add("onmouseout", "hideddrivetip()") RadioButtonListPaymentFrequency.Items.Add(ListItemSemiannually)
生成的 HTML...
<table id="RadioButtonListPaymentFrequency" border="0">
<tbody>
<tr>
<td>
<input id="RadioButtonListPaymentFrequency_0" name="RadioButtonListPaymentFrequency" value="1" type="radio">
<label for="RadioButtonListPaymentFrequency_0">One-Time Only</label>
</td>
</tr>
<tr>
<td>
<input id="RadioButtonListPaymentFrequency_1" name="RadioButtonListPaymentFrequency" value="12" type="radio">
<label for="RadioButtonListPaymentFrequency_1">Monthly</label>
</td>
</tr>
<tr>
<td>
<input id="RadioButtonListPaymentFrequency_2" name="RadioButtonListPaymentFrequency" value="4" type="radio">
<label for="RadioButtonListPaymentFrequency_2">Quarterly</label>
</td>
</tr>
<tr>
<td>
<input id="RadioButtonListPaymentFrequency_3" name="RadioButtonListPaymentFrequency" value="2" type="radio">
<label for="RadioButtonListPaymentFrequency_3">Semiannually</label>
</td>
</tr>
</tbody>
</table>