Javascript 在ajaxToolkit ModalPopupXtender中处理RadioButtonList SelectedIndexChanged事件而不回发
在我的表格中,我使用的是AjaxToolkit ModalPopupXtender。PopupControlId已设置为具有RadioButtonList和dropdownlist的面板。弹出的面板如下所示:Javascript 在ajaxToolkit ModalPopupXtender中处理RadioButtonList SelectedIndexChanged事件而不回发,javascript,jquery,Javascript,Jquery,在我的表格中,我使用的是AjaxToolkit ModalPopupXtender。PopupControlId已设置为具有RadioButtonList和dropdownlist的面板。弹出的面板如下所示: <asp:Panel ID="PopUpWindowPanel" runat="server" Visible="false" BorderStyle="Solid"> <table cellpadding="2"
<asp:Panel ID="PopUpWindowPanel" runat="server" Visible="false" BorderStyle="Solid">
<table cellpadding="2" cellspacing="0" width="100%" border="0" class="dataTbl">
<tr>
<td class="left">
<asp:RadioButtonList ID="RdBtnLstSortOptions" runat="server">
<asp:ListItem Text="No change." Selected="True"
Value="None"></asp:ListItem>
<asp:ListItem Text="Some Change."
Value="Existing"></asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td class="left">
<asp:Label ID="lblList" runat="server">List:</asp:Label>
<asp:DropDownList ID="ddlList" runat="server" Visible="false">
</asp:DropDownList>
</td>
</tr>
<tr>
<td colspan="3">
<div class="divBtn">
<asp:LinkButton ID="btnDone" class="button" runat="server" OnClick="btnDone_Click">OK</asp:LinkButton>
<asp:LinkButton ID="btnCloseProfile" class="button" runat="server">Cancel</asp:LinkButton>
</div>
</td>
</tr>
</table>
</asp:Panel>
名单:
好啊
取消
现在,我想要的是,当用户选择带有Text=“Some Change.”和Value=“Existing”的Listitem时,只有这样才能显示带有id=“ddlList”的dropdownlist,否则它必须隐藏。我在页面加载时在服务器端填充此列表。因为这是ajaxcontrol,所以我不想要任何回发,因此我尝试用javascript/jquery处理这个问题。我是Javascript/Jquery的初学者,因此不知道如何正确地执行此操作。我写了一些JQuery,类似于这样:
<asp:Panel ID="PopUpWindowPanel" runat="server" Visible="false" BorderStyle="Solid">
<table cellpadding="2" cellspacing="0" width="100%" border="0" class="dataTbl">
<tr>
<td class="left">
<asp:RadioButtonList ID="RdBtnLstSortOptions" runat="server">
<asp:ListItem Text="No change." Selected="True"
Value="None"></asp:ListItem>
<asp:ListItem Text="Some Change."
Value="Existing"></asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td class="left">
<asp:Label ID="lblList" runat="server">List:</asp:Label>
<asp:DropDownList ID="ddlList" runat="server" Visible="false">
</asp:DropDownList>
</td>
</tr>
<tr>
<td colspan="3">
<div class="divBtn">
<asp:LinkButton ID="btnDone" class="button" runat="server" OnClick="btnDone_Click">OK</asp:LinkButton>
<asp:LinkButton ID="btnCloseProfile" class="button" runat="server">Cancel</asp:LinkButton>
</div>
</td>
</tr>
</table>
</asp:Panel>
函数pageLoad()
{
$find(“”)。添加所选索引已更改(
函数(发送方,参数){
var selectedValue=$(this.val();
如果($.trim(selectedValue)=“现有”){
//显示下拉列表
}
否则{//显示隐藏下拉列表}
});
}
我的问题是如何正确编写jquery/javascript,以便在选中的单选按钮选项上显示dropdownlist。谢谢。当您使用服务器控件的
Visible=False
时,它根本不会在客户端上呈现,因此您无法显示它。您可以做的是使用Visible=true
和style=“display:none”
渲染它。
然后使用:
$find('').add_selectedIndexChanged(
function (sender, args) {
var selectedValue = $(this).val();
if ($.trim(selectedValue) == 'Existing') {
$get('<%= ddlList.ClientID %>').style.display="block";
// show the dropdown list ddlList
}
else { //show the hide the dropdown list ddlList }
});
$find(“”)。添加所选索引已更改(
函数(发送方,参数){
var selectedValue=$(this.val();
如果($.trim(selectedValue)=“现有”){
$get(“”).style.display=“block”;
//显示下拉列表
}
否则{//显示隐藏下拉列表}
});
这对我很有效
$("#<%=RdBtnLstPresortOptions.ClientID%>").change(function () {
var rbvalue = $("input[@name=<%=RdBtnLstPresortOptions.UniqueID%>]:radio:checked").val();
if (rbvalue == "Existing") {
$("#<%=ddlList.ClientID%>").css("display", "block");
$("#<%=lblList.ClientID%>").css("display", "block");
} else if (rbvalue == "None") {
$("#<%=ddlList.ClientID%>").css("display", "none");
$("#<%=lblList.ClientID%>").css("display", "none");
} else {
}
});
$(“#”)更改(函数(){
var rbvalue=$(“输入[@name=]:收音机:已选中”).val();
如果(rbvalue==“现有”){
$(“#”)css(“显示”、“块”);
$(“#”)css(“显示”、“块”);
}否则如果(rbvalue==“无”){
$(“#”)css(“显示”、“无”);
$(“#”)css(“显示”、“无”);
}否则{
}
});
函数的调用也是这样做的:$(“#”)更改(函数(),即不需要参数。