[英]how to get correct ClientID
更新:asp.net
<asp:RadioButtonList runat="server" ID="rbl" RepeatDirection="Horizontal">
<asp:ListItem Text="None" Value="0" Selected="True" Enabled="true" />
<asp:ListItem Text="Float" Value="1" Selected="False" Enabled="true" />
<asp:ListItem Text="Float1" Value="2" Selected="False" Enabled="true" />
<asp:ListItem Text="Center" Value="3" Selected="False" Enabled="false" />
</asp:RadioButtonList>
當我查看源代碼時,它就是渲染的內容:
$('#ctl00_ctl00_ContentMain_rbl').hover(
function (){
$('#div1').dialog({title: "some title"});
$('#div1').dialog('open');
}
);
正確的ctl00_ctl00_ContentMain_rbl_0, ctl00_ctl00_ContentMain_rbl_1, ctl00_ctl00_ContentMain_rbl_2
是: ctl00_ctl00_ContentMain_rbl_0, ctl00_ctl00_ContentMain_rbl_1, ctl00_ctl00_ContentMain_rbl_2
代碼不起作用,當我嘗試閱讀時,它沒有給我正確的ClientID名稱。對於此問題,反過來又是什么,請定義類名稱?
$('#<%= rbl.ClientID %>').hover(
function (){
$('#div1').dialog({title: "Float Images Left"});
$('#div1').dialog('open');
} );
如果要對單選按鈕進行懸停操作,則必須定位輸入
$('#<%= rbl.ClientID %> input').hover(
function (){
$('#div1').dialog({title: "Float Images Left"});
$('#div1').dialog('open');
}
);
這就是我如何達到我想要的。
為每個列表項定義類
<asp:RadioButtonList runat="server" ID="rbl" RepeatDirection="Horizontal">
<asp:ListItem class="rb0" Text="None" Value="0" Selected="True" Enabled="true" />
<asp:ListItem class="rb1" Text="Float" Value="1" Selected="False" Enabled="true" />
<asp:ListItem class="rb2" Text="Float1" Value="2" Selected="False" Enabled="true" />
<asp:ListItem class="rb3" Text="Center" Value="3" Selected="False" Enabled="false" />
</asp:RadioButtonList>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.